Subject: bin/3809: vnconfig dumps core if geomspec is invalid (such as 100/2/10)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@ba2.so-net.or.jp>
List: netbsd-bugs
Date: 06/29/1997 13:17:05
>Number: 3809
>Category: bin
>Synopsis: vnconfig dumps core if geomspec is invalid (such as 100/2/10)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jun 28 21:35:00 1997
>Last-Modified:
>Originator: enami tsugutomo
>Organization:
>Release: NetBSD-current 1997 June 27
>Environment:
System: NetBSD pavlov.enami.ba2.so-net.or.jp 1.2G NetBSD 1.2G (PAVLOV) #299: Sat Jun 28 11:55:32 JST 1997 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/PAVLOV i386
>Description:
vnconfig dumps core if geomspec is invalid (such as 100/2/10)
>How-To-Repeat:
king-show# vnconfig -v -c /dev/vnd1d /var/tmp/tako 100/2/10
Segmentation fault (core dumped)
>Fix:
Since strsep(char **stringp, ...) sets *stringp if no delimiter
is found, `cp' in macro GETARG should be checked against NULL
before used.
In addtion, while I'm here, found that return value of getgeom
is not used. Though ioctl may fail if geometory is invalid,
it is better warn or signal error earlier.
Here is my fix:
Index: vnconfig.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/usr.sbin/vnconfig/vnconfig.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 vnconfig.c
--- vnconfig.c 1997/06/24 18:40:24 1.1.1.3
+++ vnconfig.c 1997/06/29 04:09:35
@@ -171,6 +171,8 @@
vndio.vnd_file = file;
if (geom != NULL) {
rv = getgeom(&vndio.vnd_geom, geom);
+ if (rv)
+ errx(1, "invalid geometory");
vndio.vnd_flags = VNDIOF_HASGEOM;
} else if (tabname != NULL) {
lp = getdiskbyname(tabname);
@@ -228,7 +230,7 @@
#define GETARG(arg) \
do { \
- if (*cp == '\0') \
+ if (cp == NULL || *cp == '\0') \
return (1); \
arg = strsep(&cp, "/"); \
if (arg == NULL) \
>Audit-Trail:
>Unformatted: