Subject: bin/18785: config can read directories
To: None <gnats-bugs@gnats.netbsd.org>
From: Julio Merino <jmmv@menta.net>
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
>Closed-Date:
>Last-Modified:
>Originator: Julio Merino
>Release: NetBSD 1.6I
>Organization:
HispaBSD
>Environment:
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
>Description:
The `config' program is able to open directories as if they were
normal configuration files. This should not be allowed.
>How-To-Repeat:
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.
>Fix:
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;
>Release-Note:
>Audit-Trail:
>Unformatted: