mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00: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
1 changed files with 8 additions and 4 deletions
|
@ -53,13 +53,17 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params
|
||||||
if (path.is_empty() || !path.view().starts_with('/'))
|
if (path.is_empty() || !path.view().starts_with('/'))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
auto permissions = copy_string_from_user(params.permissions);
|
OwnPtr<KString> permissions;
|
||||||
if (permissions.is_null())
|
{
|
||||||
return EFAULT;
|
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...
|
// Let's work out permissions first...
|
||||||
unsigned new_permissions = 0;
|
unsigned new_permissions = 0;
|
||||||
for (const char permission : permissions) {
|
for (const char permission : permissions->view()) {
|
||||||
switch (permission) {
|
switch (permission) {
|
||||||
case 'r':
|
case 'r':
|
||||||
new_permissions |= UnveilAccess::Read;
|
new_permissions |= UnveilAccess::Read;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue