Merge bitcoin-core/secp256k1#952: Avoid computing out-of-bounds pointer.

9be7b0f083 Avoid computing out-of-bounds pointer. (Tim Ruffing)

Pull request description:

  This is a pedantic case of UB.

  Spotted in #879.

ACKs for top commit:
  elichai:
    ACK 9be7b0f083
  practicalswift:
    cr ACK 9be7b0f083
  sipa:
    ACK 9be7b0f083

Tree-SHA512: a9d028c4cdb37ad0d5fcf0d2f678eef732a653d37155a69a20272c6b283c28e083172485d7a37dc4a7c6100b22a6f5b6a92e729239031be228cc511842ee35e8
This commit is contained in:
Tim Ruffing 2021-10-17 10:55:21 +02:00
commit 920a0e5fa6
No known key found for this signature in database
GPG Key ID: 8C461CCD293F6011
1 changed files with 1 additions and 1 deletions

View File

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