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

Side by Side Diff: testing/libfuzzer/fuzzers/brotli_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 unified diff | Download patch
« no previous file with comments | « testing/libfuzzer/fuzzers/BUILD.gn ('k') | third_party/brotli/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stddef.h>
6 #include <stdint.h>
7
8 #include "third_party/brotli/include/brotli/decode.h"
9
10 // Entry point for LibFuzzer.
11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
12 size_t addend = 0;
13 if (size > 0)
14 addend = data[size - 1] & 7;
15 const uint8_t* next_in = data;
16
17 const int kBufferSize = 1024;
18 uint8_t* buffer = new uint8_t[kBufferSize];
19 BrotliDecoderState* state = BrotliDecoderCreateInstance(0, 0, 0);
20
21 if (addend == 0)
22 addend = size;
23 /* Test both fast (addend == size) and slow (addend <= 7) decoding paths. */
24 for (size_t i = 0; i < size;) {
25 size_t next_i = i + addend;
26 if (next_i > size)
27 next_i = size;
28 size_t avail_in = next_i - i;
29 i = next_i;
30 BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT;
31 while (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) {
32 size_t avail_out = kBufferSize;
33 uint8_t* next_out = buffer;
34 size_t total_out;
35 result = BrotliDecoderDecompressStream(
36 state, &avail_in, &next_in, &avail_out, &next_out, &total_out);
37 }
38 if (result != BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT)
39 break;
40 }
41
42 BrotliDecoderDestroyInstance(state);
43 delete[] buffer;
44 return 0;
45 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/fuzzers/BUILD.gn ('k') | third_party/brotli/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698