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:06:36 +0000 (13:06 +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 9256049d1588143b4189065ad9359a07b3272ef0..2a13388bfa5de5d1b3bbd1acd366c8c21bf43f1e 100644 (file)
@@ -903,9 +903,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
          */