mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-25 06:45:28 +00:00
LibFuzzer documentation [1] states that all return values except for 0 and -1 are currently reserved for future use. -1 is a special return value that causes LibFuzzer to not add a testing input to the testing corpus, regardless of the code coverage that it causes. [1] https://llvm.org/docs/LibFuzzer.html
33 lines
700 B
C++
33 lines
700 B
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#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::try_create(wav_data);
|
|
|
|
if (wav_or_error.is_error())
|
|
return 0;
|
|
|
|
auto wav = wav_or_error.release_value();
|
|
|
|
for (;;) {
|
|
auto samples = wav->get_more_samples();
|
|
if (samples.is_error())
|
|
return 0;
|
|
if (samples.value().size() > 0)
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|