In d2i_test return error for malloc failure.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 22 Apr 2016 17:37:42 +0000 (18:37 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 22 Apr 2016 23:29:03 +0000 (00:29 +0100)
Bad ASN.1 data should never be able to trigger a malloc failure so return
an error in d2i_test if a malloc failure occurs.

Reviewed-by: Richard Levitte <levitte@openssl.org>
test/d2i_test.c

index 49882a3828599ed4e6506f860d656e9c5a03d937..78adf489dd38ba7398a31576c6b0c2ea859e8f7c 100644 (file)
@@ -108,6 +108,9 @@ static int execute_test(D2I_TEST_FIXTURE fixture)
         ret = 1;
 
  err:
+    /* Don't indicate success for memory allocation errors */
+    if (ret == 1 && ERR_GET_REASON(ERR_peek_error()) == ERR_R_MALLOC_FAILURE)
+        ret = 0;
     BIO_free(bio);
     OPENSSL_free(der);
     ASN1_item_free(value, item_type);