From d9dd49c0282faaecd5dac2c83ba480b7ba02e48a Mon Sep 17 00:00:00 2001 From: schwarze Date: Sun, 5 Feb 2012 18:51:18 +0000 Subject: Do not insert an empty ENTRY into the manpath list; it's useless and causes out-of-bounds array access later. While here, remove two unused local variables and two unused struct members. From Tobias Ulmer on tech@, thanks. "off to you" deraadt@ --- usr.bin/man/man.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'usr.bin/man/man.c') diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c index 56143bdda25..2499d056797 100644 --- a/usr.bin/man/man.c +++ b/usr.bin/man/man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man.c,v 1.44 2012/01/05 21:46:15 schwarze Exp $ */ +/* $OpenBSD: man.c,v 1.45 2012/02/05 18:51:18 schwarze Exp $ */ /* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */ /* @@ -95,7 +95,6 @@ main(int argc, char *argv[]) extern char *optarg; extern int optind; TAG *searchlist; - ENTRY *ep; glob_t pg; size_t len; int ch, f_cat, f_how, found; @@ -339,6 +338,10 @@ parse_path(TAG *t, char *path) char *p, *slashp; while ((p = strsep(&path, ":")) != NULL) { + /* Skip empty fields */ + if (*p == '\0') + continue; + if ((ep = malloc(sizeof(ENTRY))) == NULL) err(1, NULL); @@ -434,7 +437,7 @@ manual(char *page, TAG *tag, glob_t *pg) { ENTRY *ep, *e_sufp, *e_tag; TAG *missp, *sufp; - int anyfound, cnt, found, globres; + int anyfound, cnt, found; char *p, buf[MAXPATHLEN]; anyfound = 0; -- cgit v1.2.3-59-g8ed1b