mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
LibArchive: Stop null-terminating StringView tar file header fields
Since 8209c2b570
was added the requires
check for copy_characters_to_buffer matched StringViews as well, which
caused unexpected null bytes to be inserted for non null-terminated
fields.
This commit is contained in:
parent
a9a90b1b58
commit
118d381091
Notes:
sideshowbarker
2024-07-17 11:50:13 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/118d381091 Pull-request: https://github.com/SerenityOS/serenity/pull/13660 Issue: https://github.com/SerenityOS/serenity/issues/13652
@ -61,10 +61,11 @@ static StringView get_field_as_string_view(char const (&field)[N])
|
||||
template<size_t N, class TSource>
|
||||
static void set_field(char (&field)[N], TSource&& source)
|
||||
{
|
||||
if constexpr (requires { source.copy_characters_to_buffer(field, N); }) {
|
||||
VERIFY(source.copy_characters_to_buffer(field, N));
|
||||
} else {
|
||||
if constexpr (requires { source.characters_without_null_termination(); }) {
|
||||
memcpy(field, source.characters_without_null_termination(), min(N, source.length()));
|
||||
} else {
|
||||
auto success = source.copy_characters_to_buffer(field, N);
|
||||
VERIFY(success);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user