1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-02 17:48:11 +00:00
serenity/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp
Tim Schumacher ad60a0b522 Fuzzers: Stop loading audio frames once the end is reached
Previously, the condition was reversed, so we would stop immediately on
a file that has at least one working chunk, and we would infinitely loop
on a file with no chunks.
2023-04-12 14:03:20 -04:00

33 lines
722 B
C++

/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Stream.h>
#include <LibAudio/WavLoader.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
if (!data)
return 0;
auto wav_data = ReadonlyBytes { data, size };
auto wav_or_error = Audio::WavLoaderPlugin::create(wav_data);
if (wav_or_error.is_error())
return 0;
auto wav = wav_or_error.release_value();
for (;;) {
auto samples = wav->load_chunks(4 * KiB);
if (samples.is_error())
return 0;
if (samples.value().size() == 0)
break;
}
return 0;
}