1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

Kernel: Store coredump metadata properties as KStrings

This patch also replaces the HashMap previously used to store coredump
properties with a plain AK::Array.
This commit is contained in:
Andreas Kling 2021-08-05 23:43:10 +02:00
parent 95669fa861
commit 33adc3a42d
6 changed files with 55 additions and 24 deletions

View file

@ -577,7 +577,8 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
m_unveiled_paths.clear();
m_unveiled_paths.set_metadata({ "/", UnveilAccess::None, false });
m_coredump_metadata.clear();
for (auto& property : m_coredump_properties)
property = {};
auto current_thread = Thread::current();
current_thread->clear_signals();

View file

@ -61,16 +61,15 @@ KResultOr<FlatPtr> Process::sys$set_coredump_metadata(Userspace<const Syscall::S
return EINVAL;
if (params.value.length > 16 * KiB)
return EINVAL;
auto copied_key = copy_string_from_user(params.key.characters, params.key.length);
if (copied_key.is_null())
return EFAULT;
auto copied_value = copy_string_from_user(params.value.characters, params.value.length);
if (copied_value.is_null())
return EFAULT;
if (!m_coredump_metadata.contains(copied_key) && m_coredump_metadata.size() >= 16)
return EFAULT;
m_coredump_metadata.set(move(copied_key), move(copied_value));
return 0;
auto key_or_error = try_copy_kstring_from_user(params.key);
if (key_or_error.is_error())
return key_or_error.error();
auto key = key_or_error.release_value();
auto value_or_error = try_copy_kstring_from_user(params.value);
if (value_or_error.is_error())
return value_or_error.error();
auto value = value_or_error.release_value();
return set_coredump_property(move(key), move(value));
}
}