diff options
author | minkikim89 <minkikim89@gmail.com> | 2020-04-20 00:31:26 +0900 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-05-27 14:50:55 -0700 |
commit | 2b473a666d183b7d097a69facf6a20125c20274e (patch) | |
tree | dd32da41f4f92758f368f71e03ea4628066bbb61 /memcached.c | |
parent | 2b7a9ed0c8dfa5a6a489ad6a6a6e90ac43de70f4 (diff) | |
download | memcached-2b473a666d183b7d097a69facf6a20125c20274e.tar.gz |
Changed the parts using strtol to use safe_strtol
Diffstat (limited to 'memcached.c')
-rw-r--r-- | memcached.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/memcached.c b/memcached.c index 6bdd525..8b5ee89 100644 --- a/memcached.c +++ b/memcached.c @@ -5523,7 +5523,10 @@ static void process_verbosity_command(conn *c, token_t *tokens, const size_t nto set_noreply_maybe(c, tokens, ntokens); - level = strtoul(tokens[1].value, NULL, 10); + if (!safe_strtoul(tokens[1].value, (uint32_t*)&level)) { + out_string(c, "CLIENT_ERROR bad command line format"); + return; + } settings.verbose = level > MAX_VERBOSITY_LEVEL ? MAX_VERBOSITY_LEVEL : level; out_string(c, "OK"); return; @@ -5569,7 +5572,10 @@ static void process_slabs_automove_command(conn *c, token_t *tokens, const size_ } settings.slab_automove_ratio = ratio; } else { - level = strtoul(tokens[2].value, NULL, 10); + if (!safe_strtoul(tokens[2].value, (uint32_t*)&level)) { + out_string(c, "CLIENT_ERROR bad command line format"); + return; + } if (level == 0) { settings.slab_automove = 0; } else if (level == 1 || level == 2) { @@ -5777,7 +5783,7 @@ static void process_extstore_command(conn *c, token_t *tokens, const size_t ntok } #endif static void process_flush_all_command(conn *c, token_t *tokens, const size_t ntokens) { - time_t exptime = 0; + int32_t exptime = 0; rel_time_t new_oldest = 0; set_noreply_maybe(c, tokens, ntokens); @@ -5793,9 +5799,8 @@ static void process_flush_all_command(conn *c, token_t *tokens, const size_t nto } if (ntokens != (c->noreply ? 3 : 2)) { - exptime = strtol(tokens[1].value, NULL, 10); - if(errno == ERANGE) { - out_string(c, "CLIENT_ERROR bad command line format"); + if (!safe_strtol(tokens[1].value, &exptime)) { + out_string(c, "CLIENT_ERROR invalid exptime argument"); return; } } @@ -5849,10 +5854,8 @@ static void process_slabs_command(conn *c, token_t *tokens, const size_t ntokens return; } - src = strtol(tokens[2].value, NULL, 10); - dst = strtol(tokens[3].value, NULL, 10); - - if (errno == ERANGE) { + if (! (safe_strtol(tokens[2].value, (int32_t*)&src) + && safe_strtol(tokens[3].value, (int32_t*)&dst))) { out_string(c, "CLIENT_ERROR bad command line format"); return; } |