Skip to content

Commit 9925f90

Browse files
committed
Zeroize RSA DER buffer in d2i_RSAPrivateKey_bio before free
F-2146 wolfSSL_d2i_RSAPrivateKey_bio read PKCS#1-encoded RSA private key DER from a BIO into a heap buffer and freed it without ForceZero. Zeroize before XFREE on both success and error paths.
1 parent a82828b commit 9925f90

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/pk_rsa.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO *bio, WOLFSSL_RSA **out)
719719
key = NULL;
720720
}
721721
/* Dispose of allocated data. */
722+
if (der != NULL) {
723+
ForceZero(der, (word32)derLen);
724+
}
722725
XFREE(der, bio ? bio->heap : NULL, DYNAMIC_TYPE_TMP_BUFFER);
723726
return key;
724727
}

0 commit comments

Comments
 (0)