Skip to content

Commit 5f0b1bf

Browse files
Add null check for mac_salt
1 parent fe00662 commit 5f0b1bf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crypto/pkcs8/pkcs8_x509.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,9 @@ int PKCS12_set_mac(PKCS12 *p12, const char *password, int password_len,
13861386
}
13871387
// Generate |mac_salt| if |salt| is NULL and copy if NULL.
13881388
uint8_t *mac_salt = OPENSSL_malloc(salt_len);
1389+
if (mac_salt == NULL) {
1390+
goto out;
1391+
}
13891392
if (salt == NULL) {
13901393
if (!RAND_bytes(mac_salt, salt_len)) {
13911394
goto out;
@@ -1454,7 +1457,7 @@ int PKCS12_set_mac(PKCS12 *p12, const char *password, int password_len,
14541457
// Verify that the new password is consistent with the original. This is
14551458
// behavior specific to AWS-LC.
14561459
OPENSSL_free(p12->ber_bytes);
1457-
if(!CBB_finish(&cbb, &p12->ber_bytes, &p12->ber_len) ||
1460+
if (!CBB_finish(&cbb, &p12->ber_bytes, &p12->ber_len) ||
14581461
!PKCS12_verify_mac(p12, password, password_len)) {
14591462
CBB_cleanup(&cbb);
14601463
goto out;

0 commit comments

Comments
 (0)