summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Fuzzers
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2021-07-12 21:55:21 +0100
committerGunnar Beutner <gunnar@beutner.name>2021-07-13 01:15:46 +0200
commit448e8c6f4577f5b152aa1a4b32c606d8325ac494 (patch)
tree0cdb1cba1f5db4ab1b5434665463c3d3571685c5 /Meta/Lagom/Fuzzers
parentbc44753adb8787ce654eb7243d6c038b0337e65b (diff)
downloadserenity-448e8c6f4577f5b152aa1a4b32c606d8325ac494.zip
Lagom/Fuzzers: Add fuzzer for FLAC loader
Diffstat (limited to 'Meta/Lagom/Fuzzers')
-rw-r--r--Meta/Lagom/Fuzzers/CMakeLists.txt1
-rw-r--r--Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp23
2 files changed, 24 insertions, 0 deletions
diff --git a/Meta/Lagom/Fuzzers/CMakeLists.txt b/Meta/Lagom/Fuzzers/CMakeLists.txt
index ad7034b994..4a7d4a9654 100644
--- a/Meta/Lagom/Fuzzers/CMakeLists.txt
+++ b/Meta/Lagom/Fuzzers/CMakeLists.txt
@@ -20,6 +20,7 @@ add_simple_fuzzer(FuzzCyrillicDecoder)
add_simple_fuzzer(FuzzDeflateCompression)
add_simple_fuzzer(FuzzDeflateDecompression)
add_simple_fuzzer(FuzzELF)
+add_simple_fuzzer(FuzzFlacLoader)
add_simple_fuzzer(FuzzGemini)
add_simple_fuzzer(FuzzGIFLoader)
add_simple_fuzzer(FuzzGzipCompression)
diff --git a/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp b/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp
new file mode 100644
index 0000000000..03a5bbdc7f
--- /dev/null
+++ b/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibAudio/FlacLoader.h>
+#include <stddef.h>
+#include <stdint.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ auto flac_data = ByteBuffer::copy(data, size);
+ auto flac = make<Audio::FlacLoaderPlugin>(flac_data);
+
+ if (!flac->sniff())
+ return 1;
+
+ while (flac->get_more_samples())
+ ;
+
+ return 0;
+}