Skip to content

Commit

Permalink
Fuzzers: Add a DNS packet fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
tcl3 authored and awesomekling committed Nov 8, 2023
1 parent 2fbaeb9 commit 33ad384
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Meta/Lagom/Fuzzers/FuzzDNSPacket.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <LibDNS/Packet.h>

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())
return 0;

(void)maybe_packet.value().to_byte_buffer();
return 0;
}
2 changes: 2 additions & 0 deletions Meta/Lagom/Fuzzers/fuzzers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(FUZZER_TARGETS
Brotli
CyrillicDecoder
DDSLoader
DNSPacket
DeflateCompression
DeflateDecompression
ELF
Expand Down Expand Up @@ -80,6 +81,7 @@ set(FUZZER_DEPENDENCIES_Brotli LibCompress)
set(FUZZER_DEPENDENCIES_CSSParser LibWeb)
set(FUZZER_DEPENDENCIES_CyrillicDecoder LibTextCodec)
set(FUZZER_DEPENDENCIES_DDSLoader LibGfx)
set(FUZZER_DEPENDENCIES_DNSPacket LibDNS)
set(FUZZER_DEPENDENCIES_DeflateCompression LibCompress)
set(FUZZER_DEPENDENCIES_DeflateDecompression LibCompress)
set(FUZZER_DEPENDENCIES_ELF LibELF)
Expand Down
1 change: 1 addition & 0 deletions Userland/Utilities/test-fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
T(CSSParser) \
T(CyrillicDecoder) \
T(DDSLoader) \
T(DNSPacket) \
T(DeflateCompression) \
T(DeflateDecompression) \
T(ELF) \
Expand Down

0 comments on commit 33ad384

Please sign in to comment.