Subject: bin/18785: config can read directories
To: None <>
From: Julio Merino <>
List: netbsd-bugs
Date: 10/23/2002 20:43:25
>Number:         18785
>Category:       bin
>Synopsis:       config can read directories
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 23 11:40:00 PDT 2002
>Originator:     Julio Merino
>Release:        NetBSD 1.6I
System: NetBSD darkstar.local 1.6I NetBSD 1.6I (DARKSTAR) #26: Tue Oct 22 22:10:08 CEST 2002 jmmv@darkstar.local:/var/build/kernel/DARKSTAR i386
Architecture: i386
Machine: i386
	The `config' program is able to open directories as if they were
	normal configuration files. This should not be allowed.
	Just try this: config /tmp
	You will see an error saying that no machine identifier has been
	found, so the directory has been open and readed.
	This patch uses the special `f' flag in fopen(). According to the
	manpage, this flag is non-ansi (so I'm not sure if it can be used
	or not). Another solution could be to use stat(2).

Index: scan.l
RCS file: /cvsroot/syssrc/usr.sbin/config/scan.l,v
retrieving revision 1.33
diff -u -u -r1.33 scan.l
--- scan.l	2002/09/06 13:24:18	1.33
+++ scan.l	2002/10/23 18:19:07
@@ -196,7 +196,7 @@
 firstfile(const char *fname)
-	if ((yyin = fopen(fname, "r")) == NULL)
+	if ((yyin = fopen(fname, "rf")) == NULL)
 		return (-1);
 	yyfile = conffile = fname;
 	yyline = 1;