diff --git a/projects/mpg123/decode_fuzzer.cc b/projects/mpg123/decode_fuzzer.cc index 9dafb20f3..4fe4b2e63 100644 --- a/projects/mpg123/decode_fuzzer.cc +++ b/projects/mpg123/decode_fuzzer.cc @@ -36,7 +36,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { FuzzedDataProvider provider(data, size); while ((decode_ret != MPG123_ERR)) { if (decode_ret == MPG123_NEED_MORE) { - if (provider.remaining_bytes() == 0) { + if (provider.remaining_bytes() == 0 + || mpg123_tellframe(handle) > 10000 + || mpg123_tell_stream(handle) > 1<<20) { break; } const size_t next_size = provider.ConsumeIntegralInRange( diff --git a/projects/mpg123/read_fuzzer.c b/projects/mpg123/read_fuzzer.c index 75e9275c0..9126dd646 100644 --- a/projects/mpg123/read_fuzzer.c +++ b/projects/mpg123/read_fuzzer.c @@ -75,7 +75,8 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { do { size_t decoded_size; read_error = mpg123_read(handle, outmemory, outmemorysize, &decoded_size); - } while (read_error == MPG123_OK); + } while (read_error == MPG123_OK && mpg123_tellframe(handle) <= 10000 + && mpg123_tell_stream(handle) <= 1<<20); } mpg123_close(handle);