Fix ASN1_INTEGER handling.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 15 Apr 2016 01:37:09 +0000 (02:37 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 3 May 2016 12:05:34 +0000 (13:05 +0100)
Only treat an ASN1_ANY type as an integer if it has the V_ASN1_INTEGER
tag: V_ASN1_NEG_INTEGER is an internal only value which is never used
for on the wire encoding.

Thanks to David Benjamin <davidben@google.com> for reporting this bug.

This was found using libFuzzer.

RT#4364 (part)CVE-2016-2108.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
crypto/asn1/a_type.c
crypto/asn1/tasn_dec.c
crypto/asn1/tasn_enc.c

index af795306b5bf58da19fbd53328992eee8baee44a..bb166e8568b5b9e68c22c4e0b6e1bab78525203f 100644 (file)
@@ -126,9 +126,7 @@ int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
         result = 0;             /* They do not have content. */
         break;
     case V_ASN1_INTEGER:
-    case V_ASN1_NEG_INTEGER:
     case V_ASN1_ENUMERATED:
-    case V_ASN1_NEG_ENUMERATED:
     case V_ASN1_BIT_STRING:
     case V_ASN1_OCTET_STRING:
     case V_ASN1_SEQUENCE:
index 5a507967c894f2d8716b8a8a8ad327c4772854a9..6bdcd5c542ca56a101e5a267fbb137de8966c892 100644 (file)
@@ -901,9 +901,7 @@ int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
         break;
 
     case V_ASN1_INTEGER:
-    case V_ASN1_NEG_INTEGER:
     case V_ASN1_ENUMERATED:
-    case V_ASN1_NEG_ENUMERATED:
         tint = (ASN1_INTEGER **)pval;
         if (!c2i_ASN1_INTEGER(tint, &cont, len))
             goto err;
index f04a6892a8d9fe14f681f4dbadbbf5fedb4b39ba..f7f83e56a981405dfd172fb6f8c34c3521dec5d1 100644 (file)
@@ -611,9 +611,7 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
         break;
 
     case V_ASN1_INTEGER:
-    case V_ASN1_NEG_INTEGER:
     case V_ASN1_ENUMERATED:
-    case V_ASN1_NEG_ENUMERATED:
         /*
          * These are all have the same content format as ASN1_INTEGER
          */