xref: /aosp_15_r20/external/pdfium/testing/fuzzers/pdf_fx_date_helpers_fuzzer.cc (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2018 The PDFium Authors
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 "core/fxcrt/widestring.h"
6 #include "fxjs/fx_date_helpers.h"
7 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)8 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
9   auto* short_data = reinterpret_cast<const unsigned short*>(data);
10   size_t short_size = size / sizeof(unsigned short);
11   if (short_size > 2 && short_size < 8192) {
12     double ignore;
13     size_t short_len1 = short_size / 2;
14     size_t short_len2 = short_size - short_len1;
15     WideString input1 = WideString::FromUTF16LE(short_data, short_len1);
16     WideString input2 =
17         WideString::FromUTF16LE(short_data + short_len1, short_len2);
18     FX_ParseDateUsingFormat(input1, input2, &ignore);
19   }
20   return 0;
21 }
22