From adbfa114b691c76d07775f3f23486310088694a2 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 30 Nov 1997 05:30:38 +0000 Subject: crank line lengths a bit, and do not make assumptions about the stack --- usr.bin/apropos/apropos.c | 11 ++++++----- usr.bin/whatis/whatis.c | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/usr.bin/apropos/apropos.c b/usr.bin/apropos/apropos.c index 9bd6bc03e64..242d741da40 100644 --- a/usr.bin/apropos/apropos.c +++ b/usr.bin/apropos/apropos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apropos.c,v 1.5 1997/09/11 11:24:53 deraadt Exp $ */ +/* $OpenBSD: apropos.c,v 1.6 1997/11/30 05:30:36 deraadt Exp $ */ /* $NetBSD: apropos.c,v 1.5 1995/09/04 20:46:20 tls Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)apropos.c 8.8 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: apropos.c,v 1.5 1997/09/11 11:24:53 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: apropos.c,v 1.6 1997/11/30 05:30:36 deraadt Exp $"; #endif #endif /* not lint */ @@ -64,6 +64,8 @@ static char rcsid[] = "$OpenBSD: apropos.c,v 1.5 1997/09/11 11:24:53 deraadt Exp static int *found, foundman; +#define MAXLINELEN 8192 /* max line handled */ + void apropos __P((char **, char *, int)); void lowstr __P((char *, char *)); int match __P((char *, char *)); @@ -140,15 +142,14 @@ apropos(argv, path, buildpath) int buildpath; { char *end, *name, **p; - char buf[LINE_MAX + 1], wbuf[LINE_MAX + 1]; + char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1]; + char hold[MAXPATHLEN]; for (name = path; name; name = end) { /* through name list */ if ((end = strchr(name, ':'))) *end++ = '\0'; if (buildpath) { - char hold[MAXPATHLEN + 1]; - (void)snprintf(hold, sizeof(hold), "%s/%s", name, _PATH_WHATIS); name = hold; diff --git a/usr.bin/whatis/whatis.c b/usr.bin/whatis/whatis.c index dc062206525..d1b83fa715f 100644 --- a/usr.bin/whatis/whatis.c +++ b/usr.bin/whatis/whatis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: whatis.c,v 1.3 1997/01/15 23:43:37 millert Exp $ */ +/* $OpenBSD: whatis.c,v 1.4 1997/11/30 05:30:37 deraadt Exp $ */ /* * Copyright (c) 1987, 1993 @@ -55,7 +55,7 @@ static char sccsid[] = "@(#)whatis.c 8.5 (Berkeley) 11/26/93"; #include "../man/config.h" #include "../man/pathnames.h" -#define MAXLINELEN 256 /* max line handled */ +#define MAXLINELEN 8192 /* max line handled */ static int *found, foundman; @@ -138,15 +138,15 @@ whatis(argv, path, buildpath) { register char *end, *name, **p; char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1]; + char hold[MAXPATHLEN]; for (name = path; name; name = end) { /* through name list */ if (end = strchr(name, ':')) *end++ = '\0'; if (buildpath) { - char hold[MAXPATHLEN + 1]; - - (void)sprintf(hold, "%s/%s", name, _PATH_WHATIS); + (void)snprintf(hold, sizeof hold, "%s/%s", + name, _PATH_WHATIS); name = hold; } -- cgit v1.2.3