Set salt length after the malloc has succeeded
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
3f6c769187
commit
c2319cf9fc
@ -208,11 +208,11 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
|
|||||||
}
|
}
|
||||||
if (!saltlen)
|
if (!saltlen)
|
||||||
saltlen = PKCS12_SALT_LEN;
|
saltlen = PKCS12_SALT_LEN;
|
||||||
p12->mac->salt->length = saltlen;
|
|
||||||
if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) {
|
if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) {
|
||||||
PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
|
PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
p12->mac->salt->length = saltlen;
|
||||||
if (!salt) {
|
if (!salt) {
|
||||||
if (RAND_bytes(p12->mac->salt->data, saltlen) <= 0)
|
if (RAND_bytes(p12->mac->salt->data, saltlen) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user