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

Side by Side Diff: testing/libfuzzer/pdf_codec_fax_fuzzer.cc

Issue 2342203006: Add fuzzer for fax codec (Closed)
Patch Set: Created 4 years, 3 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/BUILD.gn ('k') | no next file » | 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 2016 The PDFium 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 <limits.h>
6
7 #include <algorithm>
8 #include <cstdint>
9 #include <memory>
10
11 #include "core/fxcodec/codec/ccodec_faxmodule.h"
12 #include "core/fxcodec/codec/ccodec_scanlinedecoder.h"
13
14 static int GetInteger(const uint8_t* data) {
15 return data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
16 }
17
18 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
19 const int kParameterSize = 21;
20 if (size < kParameterSize)
21 return 0;
22
23 int width = GetInteger(data);
24 int height = GetInteger(data + 4);
25 int K = GetInteger(data + 8);
26 int Columns = std::max(1, std::min(USHRT_MAX, GetInteger(data + 12)));
Tom Sepez 2016/09/19 16:28:48 Why are we bounding these? the decoder should guar
kcwu 2016/09/19 16:38:48 I'm not sure. I just follow the only existing call
27 int Rows = std::max(0, std::min(USHRT_MAX, GetInteger(data + 16)));
28 FX_BOOL EndOfLine = (data[20] & 0x01) == 0;
29 FX_BOOL ByteAlign = (data[20] & 0x02) == 0;
30 FX_BOOL BlackIs1 = (data[20] & 0x04) == 0;
31 data += kParameterSize;
32 size -= kParameterSize;
33
34 std::unique_ptr<CCodec_FaxModule> fax_module(new CCodec_FaxModule);
35 std::unique_ptr<CCodec_ScanlineDecoder> decoder;
36 decoder.reset(fax_module->CreateDecoder(data, size, width, height, K,
37 EndOfLine, ByteAlign, BlackIs1,
38 Columns, Rows));
39
40 int line = 0;
41 while (decoder->GetScanline(line))
42 line++;
43
44 return 0;
45 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698