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 | |
tsepez | 7cda31a | 2016-12-07 12:10:20 -0800 | [diff] [blame] | 7 | #include "core/fxcrt/cfx_retain_ptr.h" |
npm | 43c8a6a | 2016-09-30 08:37:51 -0700 | [diff] [blame] | 8 | #include "core/fxcrt/fx_string.h" |
Dan Sinclair | 95bec80 | 2017-01-19 10:27:58 -0500 | [diff] [blame] | 9 | #include "xfa/fde/css/cfde_csssyntaxparser.h" |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 10 | #include "xfa/fde/css/fde_css.h" |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 11 | #include "xfa/fgas/crt/fgas_stream.h" |
dsinclair | 9eb0db1 | 2016-07-21 12:01:39 -0700 | [diff] [blame] | 12 | #include "xfa/fxfa/parser/cxfa_widetextread.h" |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 13 | |
| 14 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 15 | CFX_WideString input = CFX_WideString::FromUTF8( |
| 16 | CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); |
tsepez | 7cda31a | 2016-12-07 12:10:20 -0800 | [diff] [blame] | 17 | |
tsepez | 7cda31a | 2016-12-07 12:10:20 -0800 | [diff] [blame] | 18 | CFDE_CSSSyntaxParser parser; |
Dan Sinclair | 9dbc3c4 | 2017-01-18 08:58:00 -0500 | [diff] [blame] | 19 | parser.Init(input.c_str(), size); |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 20 | |
Dan Sinclair | 96f482c | 2017-01-11 16:31:27 -0500 | [diff] [blame] | 21 | FDE_CSSSyntaxStatus status; |
| 22 | do { |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 23 | status = parser.DoSyntaxParse(); |
Dan Sinclair | 96f482c | 2017-01-11 16:31:27 -0500 | [diff] [blame] | 24 | } while (status != FDE_CSSSyntaxStatus::Error && |
| 25 | status != FDE_CSSSyntaxStatus::EOS); |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 26 | return 0; |
| 27 | } |