1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibDNS: Make DNS packet parsing fallible

Previously, a DNS packet containing an invalid name would be returned
with an empty name. With this change, an error is returned if any error
is encountered during parsing.
This commit is contained in:
Tim Ledbetter 2023-11-13 22:36:34 +00:00 committed by Andreas Kling
parent 95d62822bf
commit 1793f51bc6
8 changed files with 29 additions and 40 deletions

View file

@ -9,10 +9,10 @@
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
AK::set_debug_enabled(false);
auto maybe_packet = DNS::Packet::from_raw_packet({ data, size });
if (!maybe_packet.has_value())
auto packet_or_error = DNS::Packet::from_raw_packet({ data, size });
if (packet_or_error.is_error())
return 0;
(void)maybe_packet.value().to_byte_buffer();
(void)packet_or_error.release_value().to_byte_buffer();
return 0;
}