• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium OS 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 "base/logging.h"
6 #include "brillo/test_helpers.h"
7 
8 #include "puffin/src/bit_writer.h"
9 #include "puffin/src/include/puffin/common.h"
10 #include "puffin/src/include/puffin/huffer.h"
11 #include "puffin/src/puff_reader.h"
12 
13 using puffin::Buffer;
14 using puffin::BufferBitWriter;
15 using puffin::BufferPuffReader;
16 using puffin::ByteExtent;
17 using puffin::Huffer;
18 
19 namespace {
FuzzHuff(const uint8_t * data,size_t size)20 void FuzzHuff(const uint8_t* data, size_t size) {
21   BufferPuffReader puff_reader(data, size);
22   Buffer deflate_buffer(size);
23   BufferBitWriter bit_writer(deflate_buffer.data(), deflate_buffer.size());
24   Huffer huffer;
25   huffer.HuffDeflate(&puff_reader, &bit_writer);
26 }
27 
28 class Environment {
29  public:
Environment()30   Environment() {
31     // To turn off the logging.
32     logging::SetMinLogLevel(logging::LOG_FATAL);
33   }
34 };
35 
36 }  // namespace
37 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)38 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
39   static Environment env;
40 
41   FuzzHuff(data, size);
42   return 0;
43 }
44