Commit graph

6 commits

Author SHA1 Message Date
Sam Atkins
45cf40653a Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr
Apologies for the enormous commit, but I don't see a way to split this
up nicely. In the vast majority of cases it's a simple change. A few
extra places can use TRY instead of manual error checking though. :^)
2022-01-24 22:36:09 +01:00
Timothy Flynn
204a091765 LibCore: Avoid buffer overrun when invoking crypt() with a SecretString
For example, consider the following SecretString construction:

    String foo = "foo";
    auto ss = SecretString::take_ownership(foo.to_byte_buffer());

The ByteBuffer created by to_byte_buffer() will not contain the NUL
terminator. Therefore, the value returned by SecretString::characters
will not be NUL-terminated either.

Currently, the only use of SecretString is to pass its character data to
crypt(), which requires a NUL-terminated string. To ensure this cannot
result in a buffer overrun, make SecretString append a NUL terminator to
its buffer if there isn't one already.
2021-10-19 18:19:33 +02:00
Mustafa Quraish
0f749681a9 Everywhere: Use my fancy new serenityos.org email :^) 2021-09-13 20:51:50 +00:00
Brian Gianforcaro
b8cad2c9b9 LibCore: Switch to AK::secure_zero instead of platform specific APIs 2021-09-13 00:02:42 +02:00
Mustafa Quraish
500a3fb2a7 Core/SecretString: Use memset_s instead of explicit_bzero on MacOS
MacOS doesn't have `explicit_bzero`, so this was causing errors when
compiling LibCore on the host.
2021-09-12 17:11:45 +00:00
Brian Gianforcaro
3bf6902790 LibCore: Add SecretString, a buffer that is zero'd on destruction
We have a few places where we read secrets into memory, and then
do some computation on them. In these cases we should always make
sure we zero the allocations before they are free'd.

The SecureString wrapper provides this abstraction by wrapping a
ByteBuffer and calling explicit_bzero on destruction of the object.
2021-09-12 16:36:52 +02:00