From 9e4b27a8290d44043deb4a3f1ca7be909b0cd658 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 14 Nov 2024 14:58:43 +0100 Subject: [PATCH] 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 --- repos/os/src/server/fs_rom/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repos/os/src/server/fs_rom/main.cc b/repos/os/src/server/fs_rom/main.cc index 609f73bc32..478b07fdc7 100644 --- a/repos/os/src/server/fs_rom/main.cc +++ b/repos/os/src/server/fs_rom/main.cc @@ -258,7 +258,7 @@ class Fs_rom::Rom_session_component : public Rpc_object return false; } } else { - memset(_file_ds.local_addr(), 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 /* notify if the file is removed */ catch (File_system::Lookup_failed) { if (_file_size > 0) { - memset(_file_ds.local_addr(), 0x00, (size_t)_file_size); + _file_ds.clear(); _file_size = 0; Signal_transmitter(_sigh).submit(); }