Subject: bin/4292: apropos sometimes crashes
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@bga.com>
List: netbsd-bugs
Date: 10/19/1997 00:04:46
>Number:         4292
>Category:       bin
>Synopsis:       apropos sometimes crashes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 18 22:20:02 1997
>Last-Modified:
>Originator:     Dave Huang
>Organization:
	
>Release:        NetBSD-current as of October 18, 1997
>Environment:
	
System: NetBSD dahan.metonymy.com 1.2G NetBSD 1.2G (SPIFF) #142: Sat Oct 18 17:18:07 CDT 1997 khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386


>Description:
	If apropos' search path includes a nonexistant whatis.db file,
it dumps core.
>How-To-Repeat:
	The stock /etc/man.conf includes "/usr/X11R5/man/whatis.db",
which I do not have:

% apropos very
routed (8) - network RIP and router discovery routing daemon
Segmentation fault (core dumped)
>Fix:
--- /usr/src/usr.bin/apropos/apropos.c	Fri Oct 17 13:45:03 1997
+++ apropos.c	Sat Oct 18 23:56:44 1997
@@ -125,7 +125,7 @@
 			if (glob(ep->s, GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE,
 			    NULL, &pg) != 0)
 				err(1, "glob");
-			for (p = pg.gl_pathv; *p; p++)
+			for (p = pg.gl_pathv; pg.gl_pathc && *p; p++)
 				apropos(argv, *p, 0);
 			globfree(&pg);
 		}

>Audit-Trail:
>Unformatted: