From dd92dd8fb5c2cc5c9815b720128b3015382b8da4 Mon Sep 17 00:00:00 2001 From: Binbin Date: Sun, 18 Feb 2024 16:55:11 +0800 Subject: [PATCH] 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. --- src/redis-cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 13275a826..5c5c2b912 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -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;