
The ASN1_STRING_set() function takes an `int` length, make sure the argument is not inadvertently truncated when it is called from asn1_ex_c2i().
The patch addresses an integer truncation issue in the OpenSSL ASN.1/DER decoding code.
The following changes were made:
Updated the ASN.1 content length type
len parameter of asn1_ex_c2i() from int to long.Added length truncation validation
ilen variable to hold the int representation of len.long length can safely fit into an int.TOO_LONG error instead of continuing with an incorrect truncated length.Updated primitive conversion handling
prim_c2i() callback is now called only when the length can safely be represented as an int.int.Updated ASN.1 object conversion
ossl_c2i_ASN1_OBJECT().Updated ASN.1 string handling
ASN1_STRING_set0() and ASN1_STRING_set() to use the validated ilen value instead of the original potentially oversized len.These changes prevent an attacker-controlled ASN.1 length greater than the supported int range from being silently truncated and subsequently used for buffer operations. This prevents incorrect length calculations and mitigates the heap buffer over-read condition associated with CVE-2026-34180.