Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |