From 9be7b0f08340a063d961547b5d2663405f3fc162 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Wed, 16 Jun 2021 10:33:41 +0200 Subject: [PATCH] Avoid computing out-of-bounds pointer. This is a pedantic case of UB. --- src/ecdsa_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ecdsa_impl.h b/src/ecdsa_impl.h index c32141e88..8a99a178e 100644 --- a/src/ecdsa_impl.h +++ b/src/ecdsa_impl.h @@ -112,7 +112,7 @@ static int secp256k1_der_parse_integer(secp256k1_scalar *r, const unsigned char if (secp256k1_der_read_len(&rlen, sig, sigend) == 0) { return 0; } - if (rlen == 0 || *sig + rlen > sigend) { + if (rlen == 0 || rlen > (size_t)(sigend - *sig)) { /* Exceeds bounds or not at least length 1 (X.690-0207 8.3.1). */ return 0; }