blob: 43ce686c2263dd42c2172ad1ab0cffb015c0686f [file] [log] [blame]
dsinclair756d3792016-06-14 07:34:20 -07001// 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
tsepez7cda31a2016-12-07 12:10:20 -08007#include "core/fxcrt/cfx_retain_ptr.h"
Dan Sinclair3b71d262017-04-19 08:58:54 -04008#include "core/fxcrt/cfx_seekablestreamproxy.h"
npm43c8a6a2016-09-30 08:37:51 -07009#include "core/fxcrt/fx_string.h"
Dan Sinclair95bec802017-01-19 10:27:58 -050010#include "xfa/fde/css/cfde_csssyntaxparser.h"
dsinclair756d3792016-06-14 07:34:20 -070011#include "xfa/fde/css/fde_css.h"
dsinclair756d3792016-06-14 07:34:20 -070012
13extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
dsinclair756d3792016-06-14 07:34:20 -070014 CFX_WideString input = CFX_WideString::FromUTF8(
15 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
tsepez7cda31a2016-12-07 12:10:20 -080016
Dan Sinclaircff56182017-01-25 11:37:16 -050017 // If we convert the input into an empty string bail out.
18 if (input.GetLength() == 0)
19 return 0;
20
tsepez7cda31a2016-12-07 12:10:20 -080021 CFDE_CSSSyntaxParser parser;
Dan Sinclaircff56182017-01-25 11:37:16 -050022 parser.Init(input.c_str(), input.GetLength());
dsinclair756d3792016-06-14 07:34:20 -070023
Dan Sinclair96f482c2017-01-11 16:31:27 -050024 FDE_CSSSyntaxStatus status;
25 do {
dsinclair756d3792016-06-14 07:34:20 -070026 status = parser.DoSyntaxParse();
Dan Sinclair96f482c2017-01-11 16:31:27 -050027 } while (status != FDE_CSSSyntaxStatus::Error &&
28 status != FDE_CSSSyntaxStatus::EOS);
dsinclair756d3792016-06-14 07:34:20 -070029 return 0;
30}