mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 17:40:50 +00:00
Fix negtive repeat command value issue.
If command like "-1 set a b" is sent with redis-cli, it will cause a deadless loop. So some repeat value checking logic is added to avoid this.
This commit is contained in:
parent
c2e2314640
commit
b2762f1ff2
@ -1398,16 +1398,24 @@ static void repl(void) {
|
|||||||
cliRefreshPrompt();
|
cliRefreshPrompt();
|
||||||
while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) {
|
while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) {
|
||||||
if (line[0] != '\0') {
|
if (line[0] != '\0') {
|
||||||
int repeat = 1, skipargs = 0;
|
long repeat = 1;
|
||||||
char *endptr;
|
int skipargs = 0;
|
||||||
|
char *endptr = NULL;
|
||||||
|
|
||||||
argv = cliSplitArgs(line,&argc);
|
argv = cliSplitArgs(line,&argc);
|
||||||
|
|
||||||
/* check if we have a repeat command option and
|
/* check if we have a repeat command option and
|
||||||
* need to skip the first arg */
|
* need to skip the first arg */
|
||||||
if (argv && argc > 0) {
|
if (argv && argc > 0) {
|
||||||
|
errno = 0;
|
||||||
repeat = strtol(argv[0], &endptr, 10);
|
repeat = strtol(argv[0], &endptr, 10);
|
||||||
if (argc > 1 && *endptr == '\0' && repeat) {
|
if (argc > 1 && *endptr == '\0') {
|
||||||
|
if (errno == ERANGE || errno == EINVAL || repeat <= 0) {
|
||||||
|
fputs("Invalid redis-cli repeat command option value.\n", stdout);
|
||||||
|
sdsfreesplitres(argv, argc);
|
||||||
|
linenoiseFree(line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
skipargs = 1;
|
skipargs = 1;
|
||||||
} else {
|
} else {
|
||||||
repeat = 1;
|
repeat = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user