mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 20:45:08 +00:00
Kernel: Allow empty strings in validate_and_copy_string_from_user()
Sergey pointed out that we should just allow empty strings everywhere.
This commit is contained in:
parent
69de90a625
commit
2bf11b8348
1 changed files with 5 additions and 8 deletions
|
@ -1163,13 +1163,10 @@ int Process::sys$execve(const Syscall::SC_execve_params* user_params)
|
||||||
strings.resize(list.length);
|
strings.resize(list.length);
|
||||||
copy_from_user(strings.data(), list.strings, list.length * sizeof(Syscall::StringArgument));
|
copy_from_user(strings.data(), list.strings, list.length * sizeof(Syscall::StringArgument));
|
||||||
for (size_t i = 0; i < list.length; ++i) {
|
for (size_t i = 0; i < list.length; ++i) {
|
||||||
if (strings[i].length == 0) {
|
auto string = validate_and_copy_string_from_user(strings[i]);
|
||||||
output.append(String::empty());
|
if (string.is_null())
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!validate_read(strings[i].characters, strings[i].length))
|
|
||||||
return false;
|
return false;
|
||||||
output.append(copy_string_from_user(strings[i].characters, strings[i].length));
|
output.append(move(string));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -1801,10 +1798,10 @@ bool Process::validate(const Syscall::ImmutableBufferArgument<DataType, SizeType
|
||||||
|
|
||||||
String Process::validate_and_copy_string_from_user(const char* user_characters, size_t user_length) const
|
String Process::validate_and_copy_string_from_user(const char* user_characters, size_t user_length) const
|
||||||
{
|
{
|
||||||
if (!user_characters)
|
|
||||||
return {};
|
|
||||||
if (user_length == 0)
|
if (user_length == 0)
|
||||||
return String::empty();
|
return String::empty();
|
||||||
|
if (!user_characters)
|
||||||
|
return {};
|
||||||
if (!validate_read(user_characters, user_length))
|
if (!validate_read(user_characters, user_length))
|
||||||
return {};
|
return {};
|
||||||
SmapDisabler disabler;
|
SmapDisabler disabler;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue