mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Lagom/Fuzzers: Add MP3 fuzzer
This commit is contained in:
parent
50dc9a7be7
commit
0568229d81
Notes:
sideshowbarker
2024-07-18 05:37:06 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/0568229d81 Pull-request: https://github.com/SerenityOS/serenity/pull/12781 Reviewed-by: https://github.com/IdanHo ✅
2 changed files with 29 additions and 0 deletions
|
@ -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)
|
||||
|
|
28
Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp
Normal file
28
Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue