From 7aa03eaeb0f567d94a3e968f6c9bd00f5cb59a5c Mon Sep 17 00:00:00 2001 From: markm Date: Mon, 20 Aug 2001 12:52:49 +0000 Subject: Fix overflow problem when giving a username that is too long. Also minor declaration/header fixes while auditing the code. --- contrib/opie/opieinfo.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/opie/opieinfo.c b/contrib/opie/opieinfo.c index a5d0d57..614dad6 100644 --- a/contrib/opie/opieinfo.c +++ b/contrib/opie/opieinfo.c @@ -35,14 +35,17 @@ $FreeBSD$ */ #include "opie_cfg.h" +#include +#include #include +#include #if HAVE_UNISTD_H #include #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); -- cgit v1.1