Sanity check an ASN1_object_size result
authorMatt Caswell <matt@openssl.org>
Mon, 22 Aug 2016 22:41:15 +0000 (23:41 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 22 Aug 2016 23:19:15 +0000 (00:19 +0100)
If it's negative don't try and malloc it.

Reviewed-by: Tim Hudson <tjh@openssl.org>
crypto/objects/obj_dat.c

index bb50f63c0aaf4f62666c19d133e23ca7709aa5cf..259851bc00960a86b3201da8d1c7504e36ace5ff 100644 (file)
@@ -373,6 +373,8 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
     }
     /* Work out total size */
     j = ASN1_object_size(0, i, V_ASN1_OBJECT);
+    if (j < 0)
+        return NULL;
 
     if ((buf = OPENSSL_malloc(j)) == NULL)
         return NULL;