summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore
diff options
context:
space:
mode:
authorUndefine <undefine@undefine.pl>2023-02-04 18:52:06 +0100
committerAndreas Kling <kling@serenityos.org>2023-02-08 19:49:48 +0100
commitccc871e6088c85e985ffd8ef53086df09f943de5 (patch)
treee2dbea4b7d57888755dd42ed1227118c4de39040 /Userland/Libraries/LibCore
parentb4f47935a5ee1987f3e16f552178d64831e96d7f (diff)
downloadserenity-ccc871e6088c85e985ffd8ef53086df09f943de5.zip
LibCore: Propagate errors in SecretString
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r--Userland/Libraries/LibCore/GetPassword.cpp2
-rw-r--r--Userland/Libraries/LibCore/SecretString.cpp4
-rw-r--r--Userland/Libraries/LibCore/SecretString.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibCore/GetPassword.cpp b/Userland/Libraries/LibCore/GetPassword.cpp
index a0d2987b21..56d1433f1f 100644
--- a/Userland/Libraries/LibCore/GetPassword.cpp
+++ b/Userland/Libraries/LibCore/GetPassword.cpp
@@ -40,6 +40,6 @@ ErrorOr<SecretString> get_password(StringView prompt)
// Remove trailing '\n' read by getline().
password[line_length - 1] = '\0';
- return SecretString::take_ownership(password, line_length);
+ return TRY(SecretString::take_ownership(password, line_length));
}
}
diff --git a/Userland/Libraries/LibCore/SecretString.cpp b/Userland/Libraries/LibCore/SecretString.cpp
index 493427d423..58c1a02831 100644
--- a/Userland/Libraries/LibCore/SecretString.cpp
+++ b/Userland/Libraries/LibCore/SecretString.cpp
@@ -10,9 +10,9 @@
namespace Core {
-SecretString SecretString::take_ownership(char*& cstring, size_t length)
+ErrorOr<SecretString> SecretString::take_ownership(char*& cstring, size_t length)
{
- auto buffer = ByteBuffer::copy(cstring, length).release_value_but_fixme_should_propagate_errors();
+ auto buffer = TRY(ByteBuffer::copy(cstring, length));
secure_zero(cstring, length);
free(cstring);
diff --git a/Userland/Libraries/LibCore/SecretString.h b/Userland/Libraries/LibCore/SecretString.h
index f6440eb285..0e5db04d6e 100644
--- a/Userland/Libraries/LibCore/SecretString.h
+++ b/Userland/Libraries/LibCore/SecretString.h
@@ -16,7 +16,7 @@ class SecretString {
AK_MAKE_NONCOPYABLE(SecretString);
public:
- [[nodiscard]] static SecretString take_ownership(char*&, size_t);
+ [[nodiscard]] static ErrorOr<SecretString> take_ownership(char*&, size_t);
[[nodiscard]] static SecretString take_ownership(ByteBuffer&&);
[[nodiscard]] bool is_empty() const { return m_secure_buffer.is_empty(); }