Merge pull request #4832 from 0xtonyxia/fix-xadd-ID-parse

Bugfix: xadd command ID parse
This commit is contained in:
Salvatore Sanfilippo 2018-05-25 16:27:21 +02:00 committed by GitHub
commit a60f553b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -981,8 +981,10 @@ int string2ull(const char *s, unsigned long long *value) {
return 1;
}
errno = 0;
*value = strtoull(s,NULL,10);
if (errno == EINVAL || errno == ERANGE) return 0; /* strtoull() failed. */
char *endptr = NULL;
*value = strtoull(s,&endptr,10);
if (errno == EINVAL || errno == ERANGE || !(*s != '\0' && *endptr == '\0'))
return 0; /* strtoull() failed. */
return 1; /* Conversion done! */
}
@ -1061,11 +1063,10 @@ void xaddCommand(client *c) {
maxlen_arg_idx = i;
} else {
/* If we are here is a syntax error or a valid ID. */
if (streamParseIDOrReply(NULL,c->argv[i],&id,0) == C_OK) {
if (streamParseIDOrReply(c,c->argv[i],&id,0) == C_OK) {
id_given = 1;
break;
} else {
addReply(c,shared.syntaxerr);
return;
}
}