diff options
author | Rob Landley <rob@landley.net> | 2007-11-04 15:32:59 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2007-11-04 15:32:59 -0600 |
commit | 6a6dee3132db0d62a827ddf02d88c899f7c15c31 (patch) | |
tree | f4fe8113a5624100c7ae3234d3942091dded2723 /lib/lib.c | |
parent | 961e17193887734ec977e93618bba0f045951d43 (diff) | |
download | toybox-6a6dee3132db0d62a827ddf02d88c899f7c15c31.tar.gz |
Fix from Charlie Shepherd: at end of string, don't match the null terminator
as a yottabyte suffix. Also, the shift increment needs to be a long constant
on 64-bit platforms for the top three suffixes to mean anything.
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -422,8 +422,10 @@ long atolx(char *c) char *suffixes="kmgtpe", *end; long val = strtol(c, &c, 0); - end = strchr(suffixes, tolower(*c)); - if (end) val *= 1024<<((end-suffixes)*10); + if (*c) { + end = strchr(suffixes, tolower(*c)); + if (end) val *= 1024L<<((end-suffixes)*10); + } return val; } |