summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/hostname.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-14 23:00:06 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-15 12:44:35 +0200
commit0f6f86338294899fcd0e8cd9961fafbf604fa197 (patch)
tree3d72edfe04df8a8516bd0ab58ce419a42f551a14 /Kernel/Syscalls/hostname.cpp
parent9509433e25455bf8ee98a9ea718c9b4d4c84c7f6 (diff)
downloadserenity-0f6f86338294899fcd0e8cd9961fafbf604fa197.zip
Kernel: Convert remaining users of copy_string_from_user()
This patch replaces the remaining users of this API with the new try_copy_kstring_from_user() instead. Note that we still convert to a String for continued processing, and I've added FIXME about continuing work on using KString all the way.
Diffstat (limited to 'Kernel/Syscalls/hostname.cpp')
-rw-r--r--Kernel/Syscalls/hostname.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Kernel/Syscalls/hostname.cpp b/Kernel/Syscalls/hostname.cpp
index 19ca6a473c..d5ce98474a 100644
--- a/Kernel/Syscalls/hostname.cpp
+++ b/Kernel/Syscalls/hostname.cpp
@@ -32,10 +32,11 @@ KResultOr<FlatPtr> Process::sys$sethostname(Userspace<const char*> buffer, size_
if (length > 64)
return ENAMETOOLONG;
return hostname().with_exclusive([&](auto& name) -> KResultOr<FlatPtr> {
- auto copied_hostname = copy_string_from_user(buffer, length);
- if (copied_hostname.is_null())
- return EFAULT;
- name = move(copied_hostname);
+ auto name_or_error = try_copy_kstring_from_user(buffer, length);
+ if (name_or_error.is_error())
+ return name_or_error.error();
+ // FIXME: Use KString instead of String here.
+ name = name_or_error.value()->view();
return 0;
});
}