mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:17:42 +00:00
LibCore: Propagate errors in SecretString
This commit is contained in:
parent
b4f47935a5
commit
ccc871e608
3 changed files with 4 additions and 4 deletions
|
@ -40,6 +40,6 @@ ErrorOr<SecretString> get_password(StringView prompt)
|
||||||
// Remove trailing '\n' read by getline().
|
// Remove trailing '\n' read by getline().
|
||||||
password[line_length - 1] = '\0';
|
password[line_length - 1] = '\0';
|
||||||
|
|
||||||
return SecretString::take_ownership(password, line_length);
|
return TRY(SecretString::take_ownership(password, line_length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
namespace Core {
|
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);
|
secure_zero(cstring, length);
|
||||||
free(cstring);
|
free(cstring);
|
||||||
|
|
|
@ -16,7 +16,7 @@ class SecretString {
|
||||||
AK_MAKE_NONCOPYABLE(SecretString);
|
AK_MAKE_NONCOPYABLE(SecretString);
|
||||||
|
|
||||||
public:
|
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]] static SecretString take_ownership(ByteBuffer&&);
|
||||||
|
|
||||||
[[nodiscard]] bool is_empty() const { return m_secure_buffer.is_empty(); }
|
[[nodiscard]] bool is_empty() const { return m_secure_buffer.is_empty(); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue