anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit 430ba67413d0534cc80af17e7d35cb11b6c83b5c
parent 1184d044c19d7c57c9fdfd88aff506dc747888e5
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 29 Jul 2026 13:08:14 +0200

testing: check the fscanf return value against 1, not 0

Diffstat:
Msrc/testing/testing_api_cmd_truth_challenge.c | 4+++-
Msrc/testing/testing_cmd_challenge_answer.c | 4+++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/testing/testing_api_cmd_truth_challenge.c b/src/testing/testing_api_cmd_truth_challenge.c @@ -126,7 +126,9 @@ truth_challenge_cb (struct TruthChallengeState *ksls, TALER_TESTING_interpreter_fail (ksls->is); return; } - if (0 == fscanf (file, + /* fscanf returns EOF (-1), not 0, on an empty/short file; checking + `0 ==` misses that and would use the uninitialized `code` buffer. */ + if (1 != fscanf (file, "%21s", code)) { diff --git a/src/testing/testing_cmd_challenge_answer.c b/src/testing/testing_cmd_challenge_answer.c @@ -347,7 +347,9 @@ challenge_start_cb (void *af_cls, TALER_TESTING_interpreter_fail (cs->is); return; } - if (0 == fscanf (file, + /* fscanf returns EOF (-1), not 0, on an empty/short file; checking + `0 ==` misses that and would use the uninitialized `code` buffer. */ + if (1 != fscanf (file, "%21s", code)) {