From 2bf11b83480975da0e43dcb5726dbd3b9a0c480c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 25 Jan 2020 14:14:11 +0100 Subject: [PATCH] Kernel: Allow empty strings in validate_and_copy_string_from_user() Sergey pointed out that we should just allow empty strings everywhere. --- Kernel/Process.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 5ccf2074ec..02f470fb7f 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1163,13 +1163,10 @@ int Process::sys$execve(const Syscall::SC_execve_params* user_params) strings.resize(list.length); copy_from_user(strings.data(), list.strings, list.length * sizeof(Syscall::StringArgument)); for (size_t i = 0; i < list.length; ++i) { - if (strings[i].length == 0) { - output.append(String::empty()); - continue; - } - if (!validate_read(strings[i].characters, strings[i].length)) + auto string = validate_and_copy_string_from_user(strings[i]); + if (string.is_null()) return false; - output.append(copy_string_from_user(strings[i].characters, strings[i].length)); + output.append(move(string)); } return true; }; @@ -1801,10 +1798,10 @@ bool Process::validate(const Syscall::ImmutableBufferArgument