Merge pull request #10861 from padelsbach/asn-integer-overflow-copy

Fix possible memcpy length overflow in wolfSSL_d2i_ASN1_INTEGER
This commit is contained in:
David Garske
2026-07-08 15:20:05 -07:00
committed by GitHub
2 changed files with 13 additions and 0 deletions
+5
View File
@@ -1459,6 +1459,11 @@ WOLFSSL_ASN1_INTEGER* wolfSSL_d2i_ASN1_INTEGER(WOLFSSL_ASN1_INTEGER** a,
WOLFSSL_MSG("ASN.1 length not valid.");
err = 1;
}
/* Check that len + idx won't overflow a signed int */
if ((!err) && (len > INT_MAX - (int)idx)) {
WOLFSSL_MSG("ASN.1 length too large.");
err = 1;
}
/* Allocate a new ASN.1 INTEGER object. */
if ((!err) && ((ret = wolfSSL_ASN1_INTEGER_new()) == NULL)) {
err = 1;