Browse Source

Be smarter about signed vs. unsigned (produces better error messages).

OK otto@
OPENBSD_3_6
millert 20 years ago
parent
commit
2f87adf68b
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/lib/libc/stdlib/strtonum.c

+ 2
- 2
src/lib/libc/stdlib/strtonum.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: strtonum.c,v 1.1 2004/05/03 17:09:24 tedu Exp $ */
/* $OpenBSD: strtonum.c,v 1.2 2004/05/03 20:53:34 millert Exp $ */
/* /*
* Copyright (c) 2004 Ted Unangst and Todd Miller * Copyright (c) 2004 Ted Unangst and Todd Miller
* All rights reserved. * All rights reserved.
@ -48,7 +48,7 @@ strtonum(const char *numstr, long long minval, unsigned long long maxval,
if (minval > maxval || maxval < minval || if (minval > maxval || maxval < minval ||
(minval < 0 && maxval > LLONG_MAX)) (minval < 0 && maxval > LLONG_MAX))
error = INVALID; error = INVALID;
else if (minval >= 0) {
else if (maxval > LLONG_MAX ) {
ull = strtoull(numstr, &ep, 10); ull = strtoull(numstr, &ep, 10);
if (numstr == ep || *ep != '\0') if (numstr == ep || *ep != '\0')
error = INVALID; error = INVALID;


Loading…
Cancel
Save