diff --git a/Meta/Lagom/Fuzzers/FuzzBase64Roundtrip.cpp b/Meta/Lagom/Fuzzers/FuzzBase64Roundtrip.cpp new file mode 100644 index 00000000000..132996a6d50 --- /dev/null +++ b/Meta/Lagom/Fuzzers/FuzzBase64Roundtrip.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) +{ + AK::set_debug_enabled(false); + auto input = ReadonlyBytes { data, size }; + + auto encoded = MUST(encode_base64(input)); + auto decoded = MUST(decode_base64(encoded)); + + VERIFY(decoded == input); + + return 0; +} diff --git a/Meta/Lagom/Fuzzers/fuzzers.cmake b/Meta/Lagom/Fuzzers/fuzzers.cmake index ca3b6adaa4a..778166e82aa 100644 --- a/Meta/Lagom/Fuzzers/fuzzers.cmake +++ b/Meta/Lagom/Fuzzers/fuzzers.cmake @@ -1,5 +1,6 @@ set(FUZZER_TARGETS ASN1 + Base64Roundtrip BLAKE2b BMPLoader Brotli diff --git a/Userland/Utilities/test-fuzz.cpp b/Userland/Utilities/test-fuzz.cpp index e147ef36e05..16a849a3b1f 100644 --- a/Userland/Utilities/test-fuzz.cpp +++ b/Userland/Utilities/test-fuzz.cpp @@ -13,6 +13,7 @@ // TODO: Look into generating this from the authoritative list of fuzzing targets in fuzzer.cmake. #define ENUMERATE_TARGETS(T) \ T(ASN1) \ + T(Base64Roundtrip) \ T(BLAKE2b) \ T(BMPLoader) \ T(Brotli) \