summaryrefslogtreecommitdiff
path: root/libbb/xgetlarg.c
diff options
context:
space:
mode:
authorManuel Novoa III2003-03-19 09:13:01 +0000
committerManuel Novoa III2003-03-19 09:13:01 +0000
commitcad5364599eb5062d59e0c397ed638ddd61a8d5d (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /libbb/xgetlarg.c
parente01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff)
downloadbusybox-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip
busybox-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz
Major coreutils update.
Diffstat (limited to 'libbb/xgetlarg.c')
-rw-r--r--libbb/xgetlarg.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libbb/xgetlarg.c b/libbb/xgetlarg.c
index 598b0b3..06e776d 100644
--- a/libbb/xgetlarg.c
+++ b/libbb/xgetlarg.c
@@ -9,6 +9,7 @@
#include <getopt.h>
#include <errno.h>
#include <assert.h>
+#include <ctype.h>
#include "busybox.h"
@@ -19,10 +20,16 @@ extern long bb_xgetlarg(char *arg, int base, long lower, long upper)
int errno_save = errno;
assert(arg!=NULL);
+
+ /* Don't allow leading whitespace. */
+ if ((isspace)(*arg)) { /* Use an actual funciton call for minimal size. */
+ bb_show_usage();
+ }
+
errno = 0;
result = strtol(arg, &endptr, base);
- if (errno != 0 || *endptr!='\0' || result < lower || result > upper)
- show_usage();
+ if (errno != 0 || *endptr!='\0' || endptr==arg || result < lower || result > upper)
+ bb_show_usage();
errno = errno_save;
return result;
}