mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-14 01:04:38 +03:00
Kernel: Migrate sys$unveil to use the KString API
This avoids potential unhandled OOM that's possible with the old copy_string_from_user API.
This commit is contained in:
parent
2e7728bb05
commit
baec9e2d2d
Notes:
sideshowbarker
2024-07-18 08:29:15 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/baec9e2d2d2 Pull-request: https://github.com/SerenityOS/serenity/pull/8963
@ -53,13 +53,17 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
|
||||
if (path.is_empty() || !path.view().starts_with('/'))
|
||||
return EINVAL;
|
||||
|
||||
auto permissions = copy_string_from_user(params.permissions);
|
||||
if (permissions.is_null())
|
||||
return EFAULT;
|
||||
OwnPtr<KString> permissions;
|
||||
{
|
||||
auto permissions_or_error = try_copy_kstring_from_user(params.permissions);
|
||||
if (permissions_or_error.is_error())
|
||||
return permissions_or_error.error();
|
||||
permissions = permissions_or_error.release_value();
|
||||
}
|
||||
|
||||
// Let's work out permissions first...
|
||||
unsigned new_permissions = 0;
|
||||
for (const char permission : permissions) {
|
||||
for (const char permission : permissions->view()) {
|
||||
switch (permission) {
|
||||
case 'r':
|
||||
new_permissions |= UnveilAccess::Read;
|
||||
|
Loading…
Reference in New Issue
Block a user