From c2319cf9fce87a2e82efb6e58ced11a85190dc3d Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Thu, 8 Oct 2015 14:39:58 +0200 Subject: [PATCH] Set salt length after the malloc has succeeded Reviewed-by: Rich Salz Reviewed-by: Richard Levitte --- crypto/pkcs12/p12_mutl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 9da65fe616..4cf68e17ed 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -208,11 +208,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)) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } + p12->mac->salt->length = saltlen; if (!salt) { if (RAND_bytes(p12->mac->salt->data, saltlen) <= 0) return 0; -- 2.25.1