Skip to content

Commit

Permalink
Check return value of fscanf in LMS/XMSS KAT tests (open-quantum-safe…
Browse files Browse the repository at this point in the history
…#1874)

Signed-off-by: Spencer Wilson <[email protected]>
Signed-off-by: rtjk <[email protected]>
  • Loading branch information
SWilson4 authored and rtjk committed Aug 5, 2024
1 parent 234ee3c commit d6ee590
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 d6ee590

Please sign in to comment.