Browse Source

errno must be set to 0 before calling strto*()

... when using errno to determine errors

fixes #532

Change-Id: Iba1d02a86026cc878595895e91abe164cfe4d9bd
(cherry picked from commit 761ac6cb4f)
changes/16/21116/1
Richard Fuchs 8 years ago
parent
commit
70955c2e03
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      daemon/cli.c

+ 10
- 0
daemon/cli.c View File

@ -729,6 +729,7 @@ static void cli_incoming_set_maxopenfiles(str *instr, struct streambuf *replybuf
return;
}
errno = 0;
open_files_num = strtoul(instr->s, &endptr, 10);
if ((errno == ERANGE && (open_files_num == ULONG_MAX)) || (errno != 0 && open_files_num == 0)) {
@ -759,6 +760,7 @@ static void cli_incoming_set_maxsessions(str *instr, struct streambuf *replybuff
return;
}
errno = 0;
maxsessions_num = strtol(instr->s, &endptr, 10);
if ((errno == ERANGE && (maxsessions_num == LONG_MAX || maxsessions_num == LONG_MIN)) || (errno != 0 && maxsessions_num == 0)) {
@ -793,6 +795,7 @@ static void cli_incoming_set_gentimeout(str *instr, struct streambuf *replybuffe
return;
}
errno = 0;
timeout_num = strtol(instr->s, &endptr, 10);
if ((errno == ERANGE && (timeout_num == ULONG_MAX)) || (errno != 0 && timeout_num == 0) || timeout_num < 0 || timeout_num >= INT_MAX) {
@ -926,6 +929,7 @@ static void cli_incoming_ksadd(str *instr, struct streambuf *replybuffer) {
return;
}
errno = 0;
uint_keyspace_db = strtoul(instr->s, &endptr, 10);
if ((errno == ERANGE && (uint_keyspace_db == ULONG_MAX)) || (errno != 0 && uint_keyspace_db == 0)) {
@ -955,6 +959,7 @@ static void cli_incoming_ksrm(str *instr, struct streambuf *replybuffer) {
return;
}
errno = 0;
uint_keyspace_db = strtoul(instr->s, &endptr, 10);
rwlock_lock_w(&rtpe_config.config_lock);
@ -1099,6 +1104,7 @@ static void cli_incoming_set_redisallowederrors(str *instr, struct streambuf *re
return;
}
errno = 0;
allowed_errors = strtol(instr->s, &endptr, 10);
rwlock_lock_w(&rtpe_config.config_lock);
@ -1123,6 +1129,7 @@ static void cli_incoming_set_redisdisabletime(str *instr, struct streambuf *repl
return;
}
errno = 0;
seconds = strtol(instr->s, &endptr, 10);
if (seconds < 0) {
streambuf_printf(replybuffer, "Invalid redis-disable-time value %ld, must be >= 0\n", seconds);
@ -1151,6 +1158,7 @@ static void cli_incoming_set_redisconnecttimeout(str *instr, struct streambuf *r
return ;
}
errno = 0;
timeout = strtol(instr->s, &endptr, 10);
if (timeout <= 0) {
streambuf_printf(replybuffer, "Invalid redis-connect-timeout value %ld, must be > 0\n", timeout);
@ -1179,6 +1187,7 @@ static void cli_incoming_set_rediscmdtimeout(str *instr, struct streambuf *reply
return;
}
errno = 0;
timeout = strtol(instr->s, &endptr, 10);
if (timeout < 0) {
streambuf_printf(replybuffer, "Invalid redis-cmd-timeout value %ld, must be >= 0\n", timeout);
@ -1244,6 +1253,7 @@ static void cli_incoming_set_controltos(str *instr, struct streambuf *replybuffe
return ;
}
errno = 0;
tos = strtol(instr->s, &endptr, 10);
if (tos < 0 || tos > 255) {
streambuf_printf(replybuffer, "Invalid control-tos value %ld, must be between 0 and 255\n", tos);


Loading…
Cancel
Save