Fix name length limit check.
authorDr. Stephen Henson <steve@openssl.org>
Wed, 4 May 2016 15:09:06 +0000 (16:09 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 4 May 2016 16:41:20 +0000 (17:41 +0100)
The name length limit check in x509_name_ex_d2i() includes
the containing structure as well as the actual X509_NAME. This will
cause large CRLs to be rejected.

Fix by limiting the length passed to ASN1_item_ex_d2i() which will
then return an error if the passed X509_NAME exceeds the length.

RT#4531

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 4e0d184ac1dde845ba9574872e2ae5c903c81dff)

crypto/asn1/x_name.c

index a858c2993b90f4471690d52088e4aeb7912dac0a..26378fdb2a02e1548a086f5f37f92d40da3c35ad 100644 (file)
@@ -199,10 +199,8 @@ static int x509_name_ex_d2i(ASN1_VALUE **val,
     int i, j, ret;
     STACK_OF(X509_NAME_ENTRY) *entries;
     X509_NAME_ENTRY *entry;
-    if (len > X509_NAME_MAX) {
-        ASN1err(ASN1_F_X509_NAME_EX_D2I, ASN1_R_TOO_LONG);
-        return 0;
-    }
+    if (len > X509_NAME_MAX)
+        len = X509_NAME_MAX;
     q = p;
 
     /* Get internal representation of Name */