Blame SOURCES/openssl-1.1.1-cve-2023-0286-X400.patch

dc0b1f
From 2c6c9d439b484e1ba9830d8454a34fa4f80fdfe9 Mon Sep 17 00:00:00 2001
dc0b1f
From: Hugo Landau <hlandau@openssl.org>
dc0b1f
Date: Tue, 17 Jan 2023 17:45:42 +0000
dc0b1f
Subject: [PATCH 6/6] CVE-2023-0286: Fix GENERAL_NAME_cmp for x400Address
dc0b1f
 (1.1.1)
dc0b1f
dc0b1f
Reviewed-by: Paul Dale <pauli@openssl.org>
dc0b1f
Reviewed-by: Tomas Mraz <tomas@openssl.org>
dc0b1f
---
dc0b1f
 CHANGES                  | 18 +++++++++++++++++-
dc0b1f
 crypto/x509v3/v3_genn.c  |  2 +-
dc0b1f
 include/openssl/x509v3.h |  2 +-
dc0b1f
 test/v3nametest.c        |  8 ++++++++
dc0b1f
 4 files changed, 27 insertions(+), 3 deletions(-)
dc0b1f
dc0b1f
diff --git a/crypto/x509v3/v3_genn.c b/crypto/x509v3/v3_genn.c
dc0b1f
index 87a5eff47c..e54ddc55c9 100644
dc0b1f
--- a/crypto/x509v3/v3_genn.c
dc0b1f
+++ b/crypto/x509v3/v3_genn.c
dc0b1f
@@ -98,7 +98,7 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
dc0b1f
         return -1;
dc0b1f
     switch (a->type) {
dc0b1f
     case GEN_X400:
dc0b1f
-        result = ASN1_TYPE_cmp(a->d.x400Address, b->d.x400Address);
dc0b1f
+        result = ASN1_STRING_cmp(a->d.x400Address, b->d.x400Address);
dc0b1f
         break;
dc0b1f
 
dc0b1f
     case GEN_EDIPARTY:
dc0b1f
diff --git a/include/openssl/x509v3.h b/include/openssl/x509v3.h
dc0b1f
index 90fa3592ce..e61c0f29d4 100644
dc0b1f
--- a/include/openssl/x509v3.h
dc0b1f
+++ b/include/openssl/x509v3.h
dc0b1f
@@ -136,7 +136,7 @@ typedef struct GENERAL_NAME_st {
dc0b1f
         OTHERNAME *otherName;   /* otherName */
dc0b1f
         ASN1_IA5STRING *rfc822Name;
dc0b1f
         ASN1_IA5STRING *dNSName;
dc0b1f
-        ASN1_TYPE *x400Address;
dc0b1f
+        ASN1_STRING *x400Address;
dc0b1f
         X509_NAME *directoryName;
dc0b1f
         EDIPARTYNAME *ediPartyName;
dc0b1f
         ASN1_IA5STRING *uniformResourceIdentifier;
dc0b1f
diff --git a/test/v3nametest.c b/test/v3nametest.c
dc0b1f
index d1852190b8..37819da8fd 100644
dc0b1f
--- a/test/v3nametest.c
dc0b1f
+++ b/test/v3nametest.c
dc0b1f
@@ -646,6 +646,14 @@ static struct gennamedata {
dc0b1f
             0xb7, 0x09, 0x02, 0x02
dc0b1f
         },
dc0b1f
         15
dc0b1f
+    }, {
dc0b1f
+        /*
dc0b1f
+         * Regression test for CVE-2023-0286.
dc0b1f
+         */
dc0b1f
+        {
dc0b1f
+            0xa3, 0x00
dc0b1f
+        },
dc0b1f
+        2
dc0b1f
     }
dc0b1f
 };
dc0b1f
 
dc0b1f
-- 
dc0b1f
2.39.1
dc0b1f