From d761b1fb74b41a27dd8a6b0d7cbc1926ab25dbe7 Mon Sep 17 00:00:00 2001 From: Spencer Wilson Date: Mon, 29 Jul 2024 15:13:38 -0400 Subject: [PATCH 1/2] Check return value of fscanf Signed-off-by: Spencer Wilson --- tests/kat_sig_stfl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/kat_sig_stfl.c b/tests/kat_sig_stfl.c index 5c99f5d5b..735ce5002 100644 --- a/tests/kat_sig_stfl.c +++ b/tests/kat_sig_stfl.c @@ -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); @@ -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); From c37c532c666205b2d9e6198f0c36941844c47982 Mon Sep 17 00:00:00 2001 From: Spencer Wilson Date: Mon, 29 Jul 2024 15:18:25 -0400 Subject: [PATCH 2/2] Run format script Signed-off-by: Spencer Wilson --- tests/kat_sig_stfl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/kat_sig_stfl.c b/tests/kat_sig_stfl.c index 735ce5002..85b089615 100644 --- a/tests/kat_sig_stfl.c +++ b/tests/kat_sig_stfl.c @@ -312,9 +312,9 @@ OQS_STATUS sig_stfl_kat(const char *method_name, const char *katfile) { // Echo back remain if (FindMarker(fp_rsp, "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(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); @@ -324,9 +324,9 @@ OQS_STATUS sig_stfl_kat(const char *method_name, const char *katfile) { // Echo back max if (FindMarker(fp_rsp, "max = ")) { 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(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);