Lagom/Fuzzers: Add MP3 fuzzer

This commit is contained in:
Luke Wilde 2022-02-26 17:10:12 +00:00 committed by Idan Horowitz
parent 50dc9a7be7
commit 0568229d81
Notes: sideshowbarker 2024-07-18 05:37:06 +09:00
2 changed files with 29 additions and 0 deletions

View file

@ -28,6 +28,7 @@ add_simple_fuzzer(FuzzGzipDecompression LagomCompress)
add_simple_fuzzer(FuzzICOLoader LagomGfx)
add_simple_fuzzer(FuzzJPGLoader LagomGfx)
add_simple_fuzzer(FuzzMD5 LagomCrypto)
add_simple_fuzzer(FuzzMP3Loader LagomAudio)
add_simple_fuzzer(FuzzPEM LagomCrypto)
add_simple_fuzzer(FuzzPNGLoader LagomGfx)
add_simple_fuzzer(FuzzPBMLoader LagomGfx)

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibAudio/MP3Loader.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).release_value();
auto mp3 = make<Audio::MP3LoaderPlugin>(flac_data);
if (mp3->initialize().is_error())
return 1;
for (;;) {
auto samples = mp3->get_more_samples();
if (samples.is_error())
return 2;
if (samples.value()->sample_count() > 0)
break;
}
return 0;
}