Merge #650: secp256k1/src/tests.c: Properly handle sscanf return value

a11c76c59a431e3492994f71a968a838e398fb58 secp256k1/src/tests.c:  Properly handle sscanf return value (Mustapha Abiola)

Pull request description:

  This pull request fixes a bug which allows the `sh` variable to be used uninitialised
  when sscanf(3) returns EOF.

  Signed-off-by: Mustapha Abiola <mustapha@trilemma.net>

ACKs for top commit:
  sipa:
    ACK a11c76c59a431e3492994f71a968a838e398fb58.
  practicalswift:
    utACK a11c76c59a431e3492994f71a968a838e398fb58
  real-or-random:
    ACK a11c76c59a431e3492994f71a968a838e398fb58 I looked at the code

Tree-SHA512: fd9660a18e39ecf9366db94ccbcec2682b020223f4f982a4356ddf56c2fbdafa5edcd830db37be12b661c1ec0b15c57b9f34ba59ef4460187c9c2478376fbc88
This commit is contained in:
Jonas Nick 2019-08-18 22:49:23 +00:00
commit e028aa33d3
No known key found for this signature in database
GPG Key ID: 4861DBF262123605

View File

@ -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;