Skip to content

Commit

Permalink
secp256k1/src/tests.c: Properly handle sscanf return value
Browse files Browse the repository at this point in the history
This pull request fixes a bug which allows the `sh` variable to be used uninitialized when sscanf returns EOF.

Signed-off-by: Mustapha Abiola <mustapha@trilemma.net>
  • Loading branch information
Mustapha Abiola committed Jul 14, 2019
1 parent fa33017 commit a11c76c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -5180,7 +5180,7 @@ int main(int argc, char **argv) {
const char* ch = argv[2];
while (pos < 16 && ch[0] != 0 && ch[1] != 0) {
unsigned short sh;
if (sscanf(ch, "%2hx", &sh)) {
if ((sscanf(ch, "%2hx", &sh)) == 1) {
seed16[pos] = sh;
} else {
break;
Expand Down

0 comments on commit a11c76c

Please sign in to comment.