d/wmr: Fix crash on invalid firmware

Don't access invalid memory on a short firmware read.
This commit is contained in:
Jan Schmidt 2023-04-26 00:51:09 +10:00 committed by Jakob Bornecrantz
parent d326ff9890
commit f33326e90b

View file

@ -294,7 +294,7 @@ read_controller_config(struct wmr_controller_base *wcb)
// Read config block
ret = wmr_read_fw_block(wcb, 0x02, &data, &data_size);
if (ret < 0 || data == NULL)
if (ret < 0 || data == NULL || data_size < 2)
return false;
/* De-obfuscate the JSON config */