1ac26c
From 2f7530077e0ef79d98718138716bc51ca0cad658 Mon Sep 17 00:00:00 2001
1ac26c
From: Hugo Landau <hlandau@openssl.org>
1ac26c
Date: Tue, 17 Jan 2023 17:45:42 +0000
1ac26c
Subject: [PATCH 14/18] CVE-2023-0286: Fix GENERAL_NAME_cmp for x400Address
1ac26c
 (3.0)
1ac26c
1ac26c
Reviewed-by: Paul Dale <pauli@openssl.org>
1ac26c
Reviewed-by: Tomas Mraz <tomas@openssl.org>
1ac26c
---
1ac26c
 CHANGES.md                  | 19 +++++++++++++++++++
1ac26c
 crypto/x509/v3_genn.c       |  2 +-
1ac26c
 include/openssl/x509v3.h.in |  2 +-
1ac26c
 test/v3nametest.c           |  8 ++++++++
1ac26c
 4 files changed, 29 insertions(+), 2 deletions(-)
1ac26c
1ac26c
diff --git a/crypto/x509/v3_genn.c b/crypto/x509/v3_genn.c
1ac26c
index c0a7166cd0..1741c2d2f6 100644
1ac26c
--- a/crypto/x509/v3_genn.c
1ac26c
+++ b/crypto/x509/v3_genn.c
1ac26c
@@ -98,7 +98,7 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
1ac26c
         return -1;
1ac26c
     switch (a->type) {
1ac26c
     case GEN_X400:
1ac26c
-        result = ASN1_TYPE_cmp(a->d.x400Address, b->d.x400Address);
1ac26c
+        result = ASN1_STRING_cmp(a->d.x400Address, b->d.x400Address);
1ac26c
         break;
1ac26c
 
1ac26c
     case GEN_EDIPARTY:
1ac26c
diff --git a/include/openssl/x509v3.h.in b/include/openssl/x509v3.h.in
1ac26c
index d00a66a343..c087e3cf92 100644
1ac26c
--- a/include/openssl/x509v3.h.in
1ac26c
+++ b/include/openssl/x509v3.h.in
1ac26c
@@ -154,7 +154,7 @@ typedef struct GENERAL_NAME_st {
1ac26c
         OTHERNAME *otherName;   /* otherName */
1ac26c
         ASN1_IA5STRING *rfc822Name;
1ac26c
         ASN1_IA5STRING *dNSName;
1ac26c
-        ASN1_TYPE *x400Address;
1ac26c
+        ASN1_STRING *x400Address;
1ac26c
         X509_NAME *directoryName;
1ac26c
         EDIPARTYNAME *ediPartyName;
1ac26c
         ASN1_IA5STRING *uniformResourceIdentifier;
1ac26c
diff --git a/test/v3nametest.c b/test/v3nametest.c
1ac26c
index 6d2e2f8e27..0341995dde 100644
1ac26c
--- a/test/v3nametest.c
1ac26c
+++ b/test/v3nametest.c
1ac26c
@@ -644,6 +644,14 @@ static struct gennamedata {
1ac26c
             0xb7, 0x09, 0x02, 0x02
1ac26c
         },
1ac26c
         15
1ac26c
+    }, {
1ac26c
+        /*
1ac26c
+         * Regression test for CVE-2023-0286.
1ac26c
+         */
1ac26c
+        {
1ac26c
+            0xa3, 0x00
1ac26c
+        },
1ac26c
+        2
1ac26c
     }
1ac26c
 };
1ac26c
 
1ac26c
-- 
1ac26c
2.39.1
1ac26c