Check bounds on update ef.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2026-03-18 16:04:20 +01:00
parent c14a12d9d1
commit 1ced9f6267
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3

View file

@ -84,6 +84,9 @@ int cmd_update_ef(void) {
if (!file_has_data(ef)) { if (!file_has_data(ef)) {
return SW_DATA_INVALID(); return SW_DATA_INVALID();
} }
if (offset + data_len > file_get_size(ef)) {
return SW_WRONG_LENGTH();
}
uint8_t *data_merge = (uint8_t *) calloc(1, offset + data_len); uint8_t *data_merge = (uint8_t *) calloc(1, offset + data_len);
memcpy(data_merge, file_get_data(ef), offset); memcpy(data_merge, file_get_data(ef), offset);