pdf_css_fuzzer.cc revision 4d3acf4ec42bf6e838f9060103aff98fbf170794
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 <memory>
6
7#include "core/fxcrt/cfx_retain_ptr.h"
8#include "core/fxcrt/fx_string.h"
9#include "xfa/fde/css/cfde_csssyntaxparser.h"
10#include "xfa/fde/css/fde_css.h"
11#include "xfa/fgas/crt/fgas_stream.h"
12#include "xfa/fxfa/parser/cxfa_widetextread.h"
13
14extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
15  CFX_WideString input = CFX_WideString::FromUTF8(
16      CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
17
18  CFDE_CSSSyntaxParser parser;
19  parser.Init(input.c_str(), size);
20
21  FDE_CSSSyntaxStatus status;
22  do {
23    status = parser.DoSyntaxParse();
24  } while (status != FDE_CSSSyntaxStatus::Error &&
25           status != FDE_CSSSyntaxStatus::EOS);
26  return 0;
27}
28