Skip to content

Commit

Permalink
Check return value of fscanf in LMS/XMSS KAT tests (#1874)
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Wilson <spencer.wilson@uwaterloo.ca>
  • Loading branch information
SWilson4 committed Jul 29, 2024
1 parent 841e903 commit 3488f0a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/kat_sig_stfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,10 @@ OQS_STATUS sig_stfl_kat(const char *method_name, const char *katfile) {

// Echo back remain
if (FindMarker(fp_rsp, "remain = ")) {
fscanf(fp_rsp, "%llu", &sigs_remain);
if (EOF == fscanf(fp_rsp, "%llu", &sigs_remain)) {
fprintf(stderr, "[kat_stfl_sig] %s ERROR: unable to read 'remain' from <%s>\n", method_name, katfile);
goto err;
};
fprintf(fh, "remain = %llu\n", sigs_remain);
} else {
fprintf(stderr, "[kat_stfl_sig] %s ERROR: OQS_SIG_STFL_sigs_remaining failed!\n", method_name);
Expand All @@ -320,7 +323,10 @@ OQS_STATUS sig_stfl_kat(const char *method_name, const char *katfile) {

// Echo back max
if (FindMarker(fp_rsp, "max = ")) {
fscanf(fp_rsp, "%llu", &sigs_maximum);
if (EOF == fscanf(fp_rsp, "%llu", &sigs_maximum)) {
fprintf(stderr, "[kat_stfl_sig] %s ERROR: unable to read 'max' from <%s>\n", method_name, katfile);
goto err;
};
fprintf(fh, "max = %llu\n", sigs_maximum);
} else {
fprintf(stderr, "[kat_stfl_sig] %s ERROR: OQS_SIG_STFL_sigs_total failed!\n", method_name);
Expand Down

0 comments on commit 3488f0a

Please sign in to comment.