X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Fxatonum_template.c;h=9f9dc1102ce7811722e869ffd048715251655e21;hb=15ce7f5b58563c6b8183da9b5404e5b5d9ba8507;hp=205da53c8dee0ef56f5d3b15dc928b724ebb44d7;hpb=1bab1de69866c38c3e9924d23f21a90623a0a6dc;p=oweals%2Fbusybox.git diff --git a/libbb/xatonum_template.c b/libbb/xatonum_template.c index 205da53c8..9f9dc1102 100644 --- a/libbb/xatonum_template.c +++ b/libbb/xatonum_template.c @@ -21,9 +21,8 @@ unsigned type xstrtou(_range_sfx)(const char *numstr, int base, int old_errno; char *e; - /* Disallow '-' and any leading whitespace. Speed isn't critical here - * since we're parsing commandline args. So make sure we get the - * actual isspace function rather than a lnumstrer macro implementaion. */ + /* Disallow '-' and any leading whitespace. Make sure we get the + * actual isspace function rather than a macro implementaion. */ if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr)) goto inval; @@ -127,9 +126,12 @@ type xstrto(_range_sfx)(const char *numstr, int base, type r; const char *p = numstr; - if (p[0] == '-') { + /* NB: if you'll decide to disallow '+': + * at least renice applet needs to allow it */ + if (p[0] == '+' || p[0] == '-') { ++p; - ++u; /* two's complement */ + if (p[0] == '-') + ++u; /* = _MIN (01111... + 1 == 10000...) */ } r = xstrtou(_range_sfx)(p, base, 0, u, suffixes);