Fix overflow problem when giving a username that is too long.
Also minor declaration/header fixes while auditing the code.
This commit is contained in:
parent
2449bf28ad
commit
432f97766d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81973
@ -35,14 +35,17 @@ License Agreement applies to this software.
|
||||
*/
|
||||
|
||||
#include "opie_cfg.h"
|
||||
#include <sys/param.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include "opie.h"
|
||||
|
||||
/* extern char *optarg; */
|
||||
extern int errno, optind;
|
||||
/* extern int errno, optind; */
|
||||
|
||||
static char *getusername FUNCTION_NOARGS
|
||||
{
|
||||
@ -82,6 +85,11 @@ int main FUNCTION((argc, argv), int argc AND char *argv[])
|
||||
} else
|
||||
username = getusername();
|
||||
|
||||
if (strlen(username) >= MAXLOGNAME) {
|
||||
fprintf(stderr, "Username too long.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((i = opielookup(&opie, username)) && (i != 2)) {
|
||||
if (i < 0)
|
||||
fprintf(stderr, "Error opening database! (errno = %d)\n", errno);
|
||||
|
Loading…
Reference in New Issue
Block a user