From 84b03c4a38ade9c100ae40e9d5b3fabfceb59913 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 25 Feb 2007 01:57:33 +0000 Subject: shhopt rejects signed value for OPT_UINT option git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@237 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/util/shhopt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/util') diff --git a/lib/util/shhopt.c b/lib/util/shhopt.c index efb9b794..718186fa 100644 --- a/lib/util/shhopt.c +++ b/lib/util/shhopt.c @@ -430,13 +430,17 @@ optExecute(optEntry const opt, char *arg, int lng) case OPT_UINT: case OPT_ULONG: { unsigned long tmp; - char *e; + char * tailPtr; if (arg == NULL) optFatal("internal error: optExecute() called with NULL argument " "'%s'", optString(opt, lng)); - tmp = strtoul(arg, &e, 10); - if (*e) + + if (arg[0] == '-' || arg[1] == '+') + optFatal("unsigned number '%s' has a sign ('%c')", + arg, arg[0]); + tmp = strtoul(arg, &tailPtr, 10); + if (*tailPtr) optFatal("invalid number `%s'", arg); if (errno == ERANGE || (opt.type == OPT_UINT && tmp > UINT_MAX)) -- cgit 1.4.1