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

Side by Side Diff: testing/libfuzzer/fuzzers/brotli_fuzzer.cc

Issue 2537133002: Update brotli to v1.0.0-snapshot. (Closed)
Patch Set: Fixed typo Created 4 years 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "third_party/brotli/dec/decode.h" 8 #include "third_party/brotli/include/brotli/decode.h"
9 9
10 // Entry point for LibFuzzer. 10 // Entry point for LibFuzzer.
11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
12 size_t addend = 0; 12 size_t addend = 0;
13 if (size > 0) 13 if (size > 0)
14 addend = data[size - 1] & 7; 14 addend = data[size - 1] & 7;
15 const uint8_t* next_in = data; 15 const uint8_t* next_in = data;
16 16
17 const int kBufferSize = 1024; 17 const int kBufferSize = 1024;
18 uint8_t* buffer = new uint8_t[kBufferSize]; 18 uint8_t* buffer = new uint8_t[kBufferSize];
19 BrotliState* state = BrotliCreateState(0, 0, 0); 19 BrotliDecoderState* state = BrotliDecoderCreateInstance(0, 0, 0);
20 20
21 if (addend == 0) 21 if (addend == 0)
22 addend = size; 22 addend = size;
23 /* Test both fast (addend == size) and slow (addend <= 7) decoding paths. */ 23 /* Test both fast (addend == size) and slow (addend <= 7) decoding paths. */
24 for (size_t i = 0; i < size;) { 24 for (size_t i = 0; i < size;) {
25 size_t next_i = i + addend; 25 size_t next_i = i + addend;
26 if (next_i > size) 26 if (next_i > size)
27 next_i = size; 27 next_i = size;
28 size_t avail_in = next_i - i; 28 size_t avail_in = next_i - i;
29 i = next_i; 29 i = next_i;
30 BrotliResult result = BROTLI_RESULT_NEEDS_MORE_OUTPUT; 30 BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT;
31 while (result == BROTLI_RESULT_NEEDS_MORE_OUTPUT) { 31 while (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) {
32 size_t avail_out = kBufferSize; 32 size_t avail_out = kBufferSize;
33 uint8_t* next_out = buffer; 33 uint8_t* next_out = buffer;
34 size_t total_out; 34 size_t total_out;
35 result = BrotliDecompressStream( 35 result = BrotliDecoderDecompressStream(
36 &avail_in, &next_in, &avail_out, &next_out, &total_out, state); 36 state, &avail_in, &next_in, &avail_out, &next_out, &total_out);
37 } 37 }
38 if (result != BROTLI_RESULT_NEEDS_MORE_INPUT) 38 if (result != BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT)
39 break; 39 break;
40 } 40 }
41 41
42 BrotliDestroyState(state); 42 BrotliDecoderDestroyInstance(state);
43 delete[] buffer; 43 delete[] buffer;
44 return 0; 44 return 0;
45 } 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