diff options
author | Denis Vlasenko | 2006-11-24 21:54:44 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-11-24 21:54:44 +0000 |
commit | d031ffa623203b1dc756a1e02e06f261fdc30872 (patch) | |
tree | 26f4426eba02d3b7f22da62ef3af151a89c99e3f /libbb/safe_strtol.c | |
parent | b833ca9d2d705943bb980c7a705aa3f07c7b5618 (diff) | |
download | busybox-d031ffa623203b1dc756a1e02e06f261fdc30872.zip busybox-d031ffa623203b1dc756a1e02e06f261fdc30872.tar.gz |
tar: sanitize option handling
Diffstat (limited to 'libbb/safe_strtol.c')
-rw-r--r-- | libbb/safe_strtol.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/libbb/safe_strtol.c b/libbb/safe_strtol.c index a7f012f..d3bb29c 100644 --- a/libbb/safe_strtol.c +++ b/libbb/safe_strtol.c @@ -102,40 +102,38 @@ int safe_strtol(const char *arg, long* value) # define strong_alias(name, aliasname) _strong_alias (name, aliasname) # define _strong_alias(name, aliasname) \ - __asm__(".global " __C_SYMBOL_PREFIX__ #aliasname "\n" \ - ".set " __C_SYMBOL_PREFIX__ #aliasname "," __C_SYMBOL_PREFIX__ #name); + __asm__(".global " __C_SYMBOL_PREFIX__ #aliasname "\n" \ + ".set " __C_SYMBOL_PREFIX__ #aliasname "," __C_SYMBOL_PREFIX__ #name); #endif #endif int safe_strtoi(const char *arg, int* value) { - if (sizeof(long) == sizeof(int)) { + int error; + long lvalue; + if (sizeof(long) == sizeof(int)) return safe_strtol(arg, (long*)value); - } else { - int error; - long lvalue = *value; - error = safe_strtol(arg, &lvalue); - if (lvalue < INT_MIN || lvalue > INT_MAX) - return 1; - *value = (int) lvalue; - return error; - } + lvalue = *value; + error = safe_strtol(arg, &lvalue); + if (lvalue < INT_MIN || lvalue > INT_MAX) + return 1; + *value = (int) lvalue; + return error; } int safe_strtou(const char *arg, unsigned* value) { - if (sizeof(unsigned long) == sizeof(unsigned)) { + int error; + unsigned long lvalue; + if (sizeof(unsigned long) == sizeof(unsigned)) return safe_strtoul(arg, (unsigned long*)value); - } else { - int error; - unsigned long lvalue = *value; - error = safe_strtoul(arg, &lvalue); - if (lvalue > UINT_MAX) - return 1; - *value = (unsigned) lvalue; - return error; - } + lvalue = *value; + error = safe_strtoul(arg, &lvalue); + if (lvalue > UINT_MAX) + return 1; + *value = (unsigned) lvalue; + return error; } int BUG_safe_strtou32_unimplemented(void); |