Fix NULL pointer dereference in asn1_ex_i2c(), crypto/asn1/tasn_enc.c

Adds handling of V_ASN1_UNDEF to avoid NULL dereference
in case ASN1 structure contains an element of type ASN1_TYPE
without initializing its value (i.e. default constructed)

CLA: trivial

Signed-off-by: Andrey Tsygunka <aitsygunka@yandex.ru>

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27100)
This commit is contained in:
Andrey Tsygunka 2025-03-19 14:53:02 +03:00 committed by Tomas Mraz
parent 21f4bd986b
commit 8e08f9c5a0

View File

@ -565,6 +565,9 @@ static int asn1_ex_i2c(const ASN1_VALUE **pval, unsigned char *cout, int *putype
return -1;
break;
case V_ASN1_UNDEF:
return -2;
case V_ASN1_NULL:
cont = NULL;
len = 0;