mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-08-21 07:33:31 +02:00
Validate NULL parameters in wc_AesCbcEncryptWithKey (F-1376)
wc_AesCbcEncryptWithKey did not check out/in/key/iv for NULL before calling wc_AesSetKey/wc_AesCbcEncrypt, unlike its counterpart wc_AesCbcDecryptWithKey. A NULL key can reach wc_AesSetKey implementations that XMEMCPY userKey without a NULL guard (e.g. the STM32 path), causing a crash at the API boundary. Add the same NULL guard wc_AesCbcDecryptWithKey uses.
This commit is contained in:
@@ -74,6 +74,10 @@ int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||
int ret = 0;
|
||||
WC_DECLARE_VAR(aes, Aes, 1, 0);
|
||||
|
||||
if (out == NULL || in == NULL || key == NULL || iv == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
WC_ALLOC_VAR_EX(aes, Aes, 1, NULL, DYNAMIC_TYPE_TMP_BUFFER,
|
||||
return MEMORY_E);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user