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" |
Dan Sinclair | 3b71d26 | 2017-04-19 08:58:54 -0400 | [diff] [blame] | 8 | #include "core/fxcrt/cfx_seekablestreamproxy.h" |
npm | 43c8a6a | 2016-09-30 08:37:51 -0700 | [diff] [blame] | 9 | #include "core/fxcrt/fx_string.h" |
Dan Sinclair | 95bec80 | 2017-01-19 10:27:58 -0500 | [diff] [blame] | 10 | #include "xfa/fde/css/cfde_csssyntaxparser.h" |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 11 | #include "xfa/fde/css/fde_css.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) { |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 14 | CFX_WideString input = CFX_WideString::FromUTF8( |
| 15 | CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); |
tsepez | 7cda31a | 2016-12-07 12:10:20 -0800 | [diff] [blame] | 16 | |
Dan Sinclair | cff5618 | 2017-01-25 11:37:16 -0500 | [diff] [blame] | 17 | // If we convert the input into an empty string bail out. |
| 18 | if (input.GetLength() == 0) |
| 19 | return 0; |
| 20 | |
tsepez | 7cda31a | 2016-12-07 12:10:20 -0800 | [diff] [blame] | 21 | CFDE_CSSSyntaxParser parser; |
Dan Sinclair | cff5618 | 2017-01-25 11:37:16 -0500 | [diff] [blame] | 22 | parser.Init(input.c_str(), input.GetLength()); |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 23 | |
Dan Sinclair | 96f482c | 2017-01-11 16:31:27 -0500 | [diff] [blame] | 24 | FDE_CSSSyntaxStatus status; |
| 25 | do { |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 26 | status = parser.DoSyntaxParse(); |
Dan Sinclair | 96f482c | 2017-01-11 16:31:27 -0500 | [diff] [blame] | 27 | } while (status != FDE_CSSSyntaxStatus::Error && |
| 28 | status != FDE_CSSSyntaxStatus::EOS); |
dsinclair | 756d379 | 2016-06-14 07:34:20 -0700 | [diff] [blame] | 29 | return 0; |
| 30 | } |