Skip to content

Commit

Permalink
redis-cli - fix sscanf incorrect return-value check warnings (redis#1…
Browse files Browse the repository at this point in the history
…3059)

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.
  • Loading branch information
enjoy-binbin authored Feb 18, 2024
1 parent 50d6fe8 commit dd92dd8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/redis-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit dd92dd8

Please sign in to comment.