Check the return value from ASN1_INTEGER_set
authorMatt Caswell <matt@openssl.org>
Mon, 10 Sep 2018 15:23:14 +0000 (16:23 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 10 Sep 2018 16:33:53 +0000 (17:33 +0100)
Found by Coverity

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7169)

(cherry picked from commit 512d811719fc955f574090af4c3586a9aba46fa7)

crypto/pkcs12/p12_init.c

index 0322df944a4ba791223c41a76efcbe9dc03305e3..8275a23fb5c76adb9a84a3db43dc887e9aa34238 100644 (file)
@@ -70,7 +70,8 @@ PKCS12 *PKCS12_init(int mode)
         PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
-    ASN1_INTEGER_set(pkcs12->version, 3);
+    if (!ASN1_INTEGER_set(pkcs12->version, 3))
+        goto err;
     pkcs12->authsafes->type = OBJ_nid2obj(mode);
     switch (mode) {
     case NID_pkcs7_data: