Add missing data length check

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2021-11-23 13:35:48 +01:00
parent 83ad0ef45d
commit 67805dc9d1

View File

@ -411,6 +411,8 @@ namespace eap
throw winstd::win_runtime_error(__FUNCTION__ " Key import failed.");
// Import the 256-bit AES session key.
if (size < 268)
throw std::invalid_argument(__FUNCTION__ " Encrypted data too short.");
winstd::crypt_key key_aes;
if (!CryptImportKey(hProv, reinterpret_cast<LPCBYTE>(data), 268, key_rsa, 0, &key_aes))
throw winstd::win_runtime_error(__FUNCTION__ " CryptImportKey failed.");