fs_rom: use dataspace bounds for clearing

Avoid potential risk of exceeding the dataspace bounds should the stored
file size be larger than the current ds size.

Issue #3897
This commit is contained in:
Norman Feske 2024-11-14 14:58:43 +01:00 committed by Christian Helmuth
parent 4d7a5b6829
commit 9e4b27a829

View File

@ -258,7 +258,7 @@ class Fs_rom::Rom_session_component : public Rpc_object<Rom_session>
return false;
}
} else {
memset(_file_ds.local_addr<char>(), 0x00, _file_ds.size());
_file_ds.clear();
}
/* omit read if file is empty */
@ -333,7 +333,7 @@ class Fs_rom::Rom_session_component : public Rpc_object<Rom_session>
/* notify if the file is removed */
catch (File_system::Lookup_failed) {
if (_file_size > 0) {
memset(_file_ds.local_addr<char>(), 0x00, (size_t)_file_size);
_file_ds.clear();
_file_size = 0;
Signal_transmitter(_sigh).submit();
}