Skip to content

Commit 8113671

Browse files
Merge #1729: hash: Use size_t instead of int for RFC6979 outlen copy
960ba5f Use size_t instead of int for RFC6979 outlen copy (John Moffett) Pull request description: If `outlen > INT_MAX` it results in segfault or hang (when `outlen` is a multiple of 2^32) on most implementations due to conversion in: `int now = outlen` producing negative values or zero. Unreachable in current code and highly improbable in future practice, but fits contract better and fixes a couple of compiler warnings. ACKs for top commit: real-or-random: utACK 960ba5f theStack: Code-review ACK 960ba5f Tree-SHA512: b91ee2fd3e962000f1b98a42e6f3c70cb3738c639fef8c2ce0cf53f49fe55da3e5d332eabbd8cbe9cdccb4e9c0ae70d3390a41f9468fd23ded3318596548c68f
2 parents f36afb8 + 960ba5f commit 8113671

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/hash_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256
265265

266266
while (outlen > 0) {
267267
secp256k1_hmac_sha256 hmac;
268-
int now = outlen;
268+
size_t now = outlen;
269269
secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32);
270270
secp256k1_hmac_sha256_write(&hmac, rng->v, 32);
271271
secp256k1_hmac_sha256_finalize(&hmac, rng->v);

0 commit comments

Comments
 (0)