diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-12-18 16:14:31 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-12-18 16:14:31 +0000 |
commit | 951b5877caa2dbc7bbbaad4be91cc9f67bb01b24 (patch) | |
tree | fbcd5630a81148207f442e8299cc89c2d78c6e75 /lib/util | |
parent | 6636f3cb2d0e7bca933637aa232193217ea06d5b (diff) | |
download | netpbm-mirror-951b5877caa2dbc7bbbaad4be91cc9f67bb01b24.tar.gz netpbm-mirror-951b5877caa2dbc7bbbaad4be91cc9f67bb01b24.tar.xz netpbm-mirror-951b5877caa2dbc7bbbaad4be91cc9f67bb01b24.zip |
Reject obviously negative number as unsigned number
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@495 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/nstring.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/util/nstring.c b/lib/util/nstring.c index 3e2da669..0fa78c7a 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -934,7 +934,7 @@ interpret_uint(const char * const string, char * tail; unsigned long ulongValue; - errno = 0; // So we can tell if strtoul() overflowed + errno = 0; /* So we can tell if strtoul() overflowed */ ulongValue = strtoul(string, &tail, 10); @@ -944,6 +944,9 @@ interpret_uint(const char * const string, asprintfN(errorP, "Number too large"); else if (ulongValue > UINT_MAX) asprintfN(errorP, "Number too large"); + else if (string[0] == '-') + asprintfN(errorP, "Negative number"); + /* Sleazy code; string may have leading spaces. */ else { *valueP = ulongValue; *errorP = NULL; |