Fix a typo in a_enum.c.
[openssl.git] / crypto / asn1 / a_enum.c
index 61349ed003ce20c5850d19dc5092ba8d7cfe740c..56ee787a23e0cdbe8fcca1c0e338e3ef3aeb5ecc 100644 (file)
@@ -177,7 +177,12 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
                goto err;
                }
        to=s;
-       if (*p & 0x80) /* a negative number */
+       if(!len) {
+               /* Strictly speaking this is an illegal ENUMERATED but we
+                * tolerate it.
+                */
+               ret->type=V_ASN1_ENUMERATED;
+       } else if (*p & 0x80) /* a negative number */
                {
                ret->type=V_ASN1_NEG_ENUMERATED;
                if ((*p == 0xff) && (len != 1)) {