1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 11:58:13 +00:00
serenity/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp
Tim Schumacher 20f0858f67 Meta: Return 0 from the fuzzing function in most cases
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
2022-12-10 16:21:12 -07:00

30 lines
707 B
C++

/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibAudio/FlacLoader.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto flac_data = ByteBuffer::copy(data, size).release_value();
auto flac_or_error = Audio::FlacLoaderPlugin::try_create(flac_data.bytes());
if (flac_or_error.is_error())
return 0;
auto flac = flac_or_error.release_value();
for (;;) {
auto samples = flac->get_more_samples();
if (samples.is_error())
return 0;
if (samples.value().size() > 0)
break;
}
return 0;
}