From: Alessandro Ghedini Date: Thu, 8 Oct 2015 12:39:58 +0000 (+0200) Subject: Set salt length after the malloc has succeeded X-Git-Tag: OpenSSL_1_0_1q~32 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=61587d65eabb90d78aad46c674f14707f4407acf;p=oweals%2Fopenssl.git Set salt length after the malloc has succeeded Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit c2319cf9fce87a2e82efb6e58ced11a85190dc3d) --- diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 5ab4bf290e..a9277827ff 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -173,11 +173,11 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, } if (!saltlen) saltlen = PKCS12_SALT_LEN; - p12->mac->salt->length = saltlen; - if (!(p12->mac->salt->data = OPENSSL_malloc(saltlen))) { + if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } + p12->mac->salt->length = saltlen; if (!salt) { if (RAND_pseudo_bytes(p12->mac->salt->data, saltlen) < 0) return 0;