diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1998-11-18 10:43:05 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1998-11-18 10:43:05 +0000 |
commit | 770d9833edf0ed5f94e9d64ea7bd3abb62c905cc (patch) | |
tree | f6fe530c54a85a59c6538d1abaf43dce287d9391 | |
parent | 15cb4ecc831ab1135584521f22b321dda2027f77 (diff) |
atoi does not do error checking on numbers, change to strtol.
pr system/641 From <lha@stacken.kth.se>
-rw-r--r-- | sbin/modunload/modunload.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sbin/modunload/modunload.c b/sbin/modunload/modunload.c index b27c00b13b4..abffb35e49f 100644 --- a/sbin/modunload/modunload.c +++ b/sbin/modunload/modunload.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modunload.c,v 1.5 1997/01/15 23:41:14 millert Exp $ */ +/* $OpenBSD: modunload.c,v 1.6 1998/11/18 10:43:04 art Exp $ */ /* $NetBSD: modunload.c,v 1.9 1995/05/28 05:23:05 jtc Exp $ */ /* @@ -74,12 +74,15 @@ main(argc, argv) 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; |