Subject: bin/6456: modload && atoi
To: None <gnats-bugs@gnats.netbsd.org>
From: None <lha@stacken.kth.se>
List: netbsd-bugs
Date: 11/18/1998 11:09:25
>Number:         6456
>Category:       bin
>Synopsis:       modload && atoi
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 18 02:20:00 1998
>Last-Modified:
>Originator:     Love
>Organization:
Stacken Computer Club
	
>Release:        1.3.2 <NetBSD-current source date>
>Environment:
	


>Description:
	atoi does no error checking
	
>How-To-Repeat:
	modunload -i foo
	
>Fix:

--- /afs/stacken.kth.se/src/NetBSD/1.3.2/sbin/modunload/modunload.c     Tue May  5 08:40:55 1998
+++ modunload.c Wed Nov 18 11:05:49 1998
@@ -82,12 +82,15 @@
        int c;
        int modnum = -1;
        char *modname = NULL;
+       char *endptr;
        struct lmc_unload ulbuf;
 
        while ((c = getopt(argc, argv, "i:n:")) != -1) {
                switch (c) {
                case 'i':
-                       modnum = atoi(optarg);
+                       modnum = strtol(optarg, &endptr, 0);
+                       if (*endptr != '\0')
+                               errx(1, "not a valid number");
                        break;  /* number */
                case 'n':
                        modname = optarg;

	
>Audit-Trail:
>Unformatted: