fix F-3025: Missing buffer-length validation in km_ecdh_decode_secret enables out-of-bounds read

This commit is contained in:
Daniel Pouzzner
2026-06-10 13:02:35 -05:00
parent 9b723b9e11
commit 1e888383bb
+8
View File
@@ -210,6 +210,14 @@ static int km_ecdh_decode_secret(const u8 * buf, unsigned int len,
return -EINVAL;
}
if (len != expected_len) {
#ifdef WOLFKM_DEBUG_ECDH
pr_err("%s: km_ecdh_decode_secret: caller passed %u, expected %zu\n",
WOLFKM_ECDH_DRIVER, len, expected_len);
#endif /* WOLFKM_DEBUG_ECDH */
return -EINVAL;
}
/* Only set the key if it was provided. */
if (params->key_size) {
params->key = (void *)ptr;