redis-cli - fix sscanf incorrect return-value check warnings (#13059)

From CodeQL: The result of scanf is only checked against 0, but
it can also return EOF.

Reported in https://github.com/redis/redis/security/code-scanning/38.
Reported in https://github.com/redis/redis/security/code-scanning/39.
This commit is contained in:
Binbin 2024-02-18 16:55:11 +08:00 committed by GitHub
parent 50d6fe8c4b
commit dd92dd8fb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -1247,7 +1247,7 @@ static int matchNoTokenArg(char **nextword, int numwords, cliCommandArg *arg) {
case ARG_TYPE_INTEGER:
case ARG_TYPE_UNIX_TIME: {
long long value;
if (sscanf(*nextword, "%lld", &value)) {
if (sscanf(*nextword, "%lld", &value) == 1) {
arg->matched += 1;
arg->matched_name = 1;
arg->matched_all = 1;
@ -1261,7 +1261,7 @@ static int matchNoTokenArg(char **nextword, int numwords, cliCommandArg *arg) {
case ARG_TYPE_DOUBLE: {
double value;
if (sscanf(*nextword, "%lf", &value)) {
if (sscanf(*nextword, "%lf", &value) == 1) {
arg->matched += 1;
arg->matched_name = 1;
arg->matched_all = 1;