diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-07-07 00:15:15 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-07-07 00:15:15 +0000 |
commit | 52964a71982af4700e470bc6dd724dad11dcb19e (patch) | |
tree | e8f8f828e960b8e4aa62680dd0a695310b13027a /sbin | |
parent | 4314133b4f972df7ef83771abf300b9d98edd503 (diff) |
Can't test an int against LONG_{MIN,MAX}; noticed on alpha
While I'm at it make the strtol() bounds checking more sensible.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/modunload/modunload.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sbin/modunload/modunload.c b/sbin/modunload/modunload.c index 6b00fb419a0..26f1e3d8827 100644 --- a/sbin/modunload/modunload.c +++ b/sbin/modunload/modunload.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modunload.c,v 1.8 1999/08/17 09:13:14 millert Exp $ */ +/* $OpenBSD: modunload.c,v 1.9 2001/07/07 00:15:14 millert Exp $ */ /* $NetBSD: modunload.c,v 1.9 1995/05/28 05:23:05 jtc Exp $ */ /* @@ -72,7 +72,7 @@ main(argc, argv) char *argv[]; { int c; - int modnum = -1; + long modnum = -1; char *modname = NULL; char *endptr; struct lmc_unload ulbuf; @@ -81,8 +81,7 @@ main(argc, argv) switch (c) { case 'i': modnum = strtol(optarg, &endptr, 0); - if (modnum == LONG_MIN || modnum == LONG_MAX || - *endptr != '\0') + if (modnum < 0 || modnum > INT_MAX || *endptr != '\0') errx(1, "not a valid number"); break; /* number */ case 'n': @@ -115,7 +114,7 @@ main(argc, argv) * Unload the requested module. */ ulbuf.name = modname; - ulbuf.id = modnum; + ulbuf.id = (int)modnum; if (ioctl(devfd, LMUNLOAD, &ulbuf) == -1) { switch (errno) { |