]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix NULL pointer dereference in `asn1_ex_i2c()`, crypto/asn1/tasn_enc.c
authorAndrey Tsygunka <aitsygunka@yandex.ru>
Wed, 19 Mar 2025 11:53:02 +0000 (14:53 +0300)
committerTomas Mraz <tomas@openssl.org>
Tue, 25 Mar 2025 18:53:49 +0000 (19:53 +0100)
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)

crypto/asn1/tasn_enc.c

index dab5f9f278f3a4f0b0cc23938b42f1861596c3e0..e0ee7604345ef7af4dfc2e2a285dcf1873e5f49e 100644 (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;