dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 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/include/fx_string.h" |
| 8 | #include "xfa/fde/css/fde_css.h" |
| 9 | #include "xfa/fde/css/fde_csssyntax.h" |
| 10 | #include "xfa/fgas/crt/fgas_stream.h" |
dsinclair | 9eb0db1 | 2016-07-21 12:01:39 -0700 | [diff] [blame^] | 11 | #include "xfa/fxfa/parser/cxfa_widetextread.h" |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 12 | |
| 13 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 14 | CFDE_CSSSyntaxParser parser; |
| 15 | |
| 16 | CFX_WideString input = CFX_WideString::FromUTF8( |
| 17 | CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); |
| 18 | std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> stream( |
dsinclair | 9eb0db1 | 2016-07-21 12:01:39 -0700 | [diff] [blame^] | 19 | new CXFA_WideTextRead(input)); |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 20 | if (!stream) |
| 21 | return 0; |
| 22 | |
| 23 | parser.Init(stream.get(), 1024); |
| 24 | |
| 25 | FDE_CSSSYNTAXSTATUS status = parser.DoSyntaxParse(); |
| 26 | while (status != FDE_CSSSYNTAXSTATUS_Error && |
| 27 | status != FDE_CSSSYNTAXSTATUS_EOS) |
| 28 | status = parser.DoSyntaxParse(); |
| 29 | |
| 30 | return 0; |
| 31 | } |