Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: third_party/brotli/fuzz/decode_fuzzer.cc

Issue 2748323002: Pickup github update for brotli fuzz target. (Closed)
Patch Set: Move fuzzer to brotli/fuzz Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/brotli/fuzz/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/brotli/fuzz/decode_fuzzer.cc
diff --git a/testing/libfuzzer/fuzzers/brotli_fuzzer.cc b/third_party/brotli/fuzz/decode_fuzzer.cc
similarity index 79%
rename from testing/libfuzzer/fuzzers/brotli_fuzzer.cc
rename to third_party/brotli/fuzz/decode_fuzzer.cc
index 4689416a9b6a427b2bcbe69c426362f39f84b15b..60c6f8e4d4dd07253e5bcaaa5b4c655c1d44249c 100644
--- a/testing/libfuzzer/fuzzers/brotli_fuzzer.cc
+++ b/third_party/brotli/fuzz/decode_fuzzer.cc
@@ -5,7 +5,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "third_party/brotli/include/brotli/decode.h"
+#include <brotli/decode.h>
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
@@ -16,6 +16,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
const int kBufferSize = 1024;
uint8_t* buffer = new uint8_t[kBufferSize];
+ /* The biggest "magic number" in brotli is 16MiB - 16, so no need to check
+ the cases with much longer output. */
+ const size_t total_out_limit = (addend == 0) ? (1 << 26) : (1 << 24);
+ size_t total_out = 0;
+
BrotliDecoderState* state = BrotliDecoderCreateInstance(0, 0, 0);
if (addend == 0)
@@ -31,10 +36,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
while (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) {
size_t avail_out = kBufferSize;
uint8_t* next_out = buffer;
- size_t total_out;
result = BrotliDecoderDecompressStream(
state, &avail_in, &next_in, &avail_out, &next_out, &total_out);
+ if (total_out > total_out_limit)
+ break;
}
+ if (total_out > total_out_limit)
+ break;
if (result != BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT)
break;
}
« no previous file with comments | « third_party/brotli/fuzz/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698