diff options
author | Luke <luke.wilde@live.co.uk> | 2021-02-28 22:43:07 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-01 11:09:09 +0100 |
commit | a66f96ff624e6d1f73dda1e382c0d0503c1508e3 (patch) | |
tree | e7af72968443b415095ad6b760746e3f5846d4d4 /Meta/Lagom/Fuzzers | |
parent | a723a977501f2aff2bdbff05411cae16e633e0e1 (diff) | |
download | serenity-a66f96ff624e6d1f73dda1e382c0d0503c1508e3.zip |
Lagom/Fuzzers: Add WAV fuzzer
Diffstat (limited to 'Meta/Lagom/Fuzzers')
-rw-r--r-- | Meta/Lagom/Fuzzers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/Meta/Lagom/Fuzzers/CMakeLists.txt b/Meta/Lagom/Fuzzers/CMakeLists.txt index 1309581e4b..b0b27afcd3 100644 --- a/Meta/Lagom/Fuzzers/CMakeLists.txt +++ b/Meta/Lagom/Fuzzers/CMakeLists.txt @@ -34,6 +34,7 @@ add_simple_fuzzer(FuzzShell) add_simple_fuzzer(FuzzTTF) add_simple_fuzzer(FuzzURL) add_simple_fuzzer(FuzzRSAKeyParsing) +add_simple_fuzzer(FuzzWAVLoader) if (NOT ENABLE_OSS_FUZZ) set(CMAKE_EXE_LINKER_FLAGS "${ORIGINAL_CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") diff --git a/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp b/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp new file mode 100644 index 0000000000..2a5e352259 --- /dev/null +++ b/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <LibAudio/WavLoader.h> +#include <stddef.h> +#include <stdint.h> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + auto wav_data = ByteBuffer::copy(data, size); + auto wav = make<Audio::WavLoaderPlugin>(wav_data); + + if (!wav->sniff()) + return 1; + + while (wav->get_more_samples()) + ; + + return 0; +} |