1 // Copyright 2017 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 <memory> 6 7 #include "core/fxcrt/fx_string.h" 8 #include "xfa/fwl/cfx_barcode.h" 9 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)10extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 11 if (size < 2 * sizeof(wchar_t)) 12 return 0; 13 14 BC_TYPE type = static_cast<BC_TYPE>(data[0] % (BC_DATAMATRIX + 1)); 15 16 // Only used one byte, but align with wchar_t for string below. 17 data += sizeof(wchar_t); 18 size -= sizeof(wchar_t); 19 20 CFX_Barcode barcode; 21 if (!barcode.Create(type)) 22 return 0; 23 24 // TODO(tsepez): Setup more options from |data|. 25 barcode.SetModuleHeight(300); 26 barcode.SetModuleWidth(420); 27 barcode.SetHeight(298); 28 barcode.SetWidth(418); 29 30 WideStringView content(reinterpret_cast<const wchar_t*>(data), 31 size / sizeof(wchar_t)); 32 33 if (!barcode.Encode(content)) 34 return 0; 35 36 // TODO(tsepez): Output to device. 37 return 0; 38 } 39