Check for error return from ASN1_object_size
authorMatt Caswell <matt@openssl.org>
Mon, 22 Aug 2016 22:39:28 +0000 (23:39 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 22 Aug 2016 23:19:15 +0000 (00:19 +0100)
Otherwise we try to malloc a -1 size.

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

index 151cafa..e60a8d3 100644 (file)
@@ -256,6 +256,9 @@ static int ocsp_add1_nonce(STACK_OF(X509_EXTENSION) **exts,
      * relies on library internals.
      */
     os.length = ASN1_object_size(0, len, V_ASN1_OCTET_STRING);
+    if (os.length < 0)
+        goto err;
+
     os.data = OPENSSL_malloc(os.length);
     if (os.data == NULL)
         goto err;