Skip to content

Commit ecc94ab

Browse files
committed
Merge dashpay#627: Guard memcmp in tests against mixed size inputs.
248bffb Guard memcmp in tests against mixed size inputs. (Gregory Maxwell) Pull request description: Reported by real-or-random. Fixes dashpay#623. ACKs for commit 248bff: practicalswift: utACK 248bffb Tree-SHA512: 29867c79d2d6852f495334a5a9129c7feac2df639dd7f752067380689b0ce9f9b35e94524834c01e698df5c0b83dc9855204ec09f5dfe488a388b509c9b861d9
2 parents 544435f + 248bffb commit ecc94ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tests.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4455,7 +4455,7 @@ int test_ecdsa_der_parse(const unsigned char *sig, size_t siglen, int certainly_
44554455
if (valid_der) {
44564456
ret |= (!roundtrips_der_lax) << 12;
44574457
ret |= (len_der != len_der_lax) << 13;
4458-
ret |= (memcmp(roundtrip_der_lax, roundtrip_der, len_der) != 0) << 14;
4458+
ret |= ((len_der != len_der_lax) || (memcmp(roundtrip_der_lax, roundtrip_der, len_der) != 0)) << 14;
44594459
}
44604460
ret |= (roundtrips_der != roundtrips_der_lax) << 15;
44614461
if (parsed_der) {
@@ -4496,7 +4496,7 @@ int test_ecdsa_der_parse(const unsigned char *sig, size_t siglen, int certainly_
44964496
ret |= (roundtrips_der != roundtrips_openssl) << 7;
44974497
if (roundtrips_openssl) {
44984498
ret |= (len_der != (size_t)len_openssl) << 8;
4499-
ret |= (memcmp(roundtrip_der, roundtrip_openssl, len_der) != 0) << 9;
4499+
ret |= ((len_der != (size_t)len_openssl) || (memcmp(roundtrip_der, roundtrip_openssl, len_der) != 0)) << 9;
45004500
}
45014501
#endif
45024502
return ret;

0 commit comments

Comments
 (0)