OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
| 8 #include <algorithm> |
| 9 #include <array> |
| 10 #include <vector> |
| 11 |
| 12 #include "third_party/icu/source/common/unicode/unistr.h" |
| 13 #include "third_party/icu/fuzzers/fuzzer_utils.h" |
| 14 |
| 15 // Taken from third_party/icu/source/data/mappings/convrtrs.txt file. |
| 16 static const std::array<const char*, 45> kConverters = { |
| 17 { |
| 18 "UTF-8", |
| 19 "utf-16be", |
| 20 "utf-16le", |
| 21 "UTF-32", |
| 22 "UTF-32BE", |
| 23 "UTF-32LE", |
| 24 "ibm866-html", |
| 25 "iso-8859-2-html", |
| 26 "iso-8859-3-html", |
| 27 "iso-8859-4-html", |
| 28 "iso-8859-5-html", |
| 29 "iso-8859-6-html", |
| 30 "iso-8859-7-html", |
| 31 "iso-8859-8-html", |
| 32 "ISO-8859-8-I", |
| 33 "iso-8859-10-html", |
| 34 "iso-8859-13-html", |
| 35 "iso-8859-14-html", |
| 36 "iso-8859-15-html", |
| 37 "iso-8859-16-html", |
| 38 "koi8-r-html", |
| 39 "koi8-u-html", |
| 40 "macintosh-html", |
| 41 "windows-874-html", |
| 42 "windows-1250-html", |
| 43 "windows-1251-html", |
| 44 "windows-1252-html", |
| 45 "windows-1253-html", |
| 46 "windows-1254-html", |
| 47 "windows-1255-html", |
| 48 "windows-1256-html", |
| 49 "windows-1257-html", |
| 50 "windows-1258-html", |
| 51 "x-mac-cyrillic-html", |
| 52 "windows-936-2000", |
| 53 "gb18030", |
| 54 "big5-html", |
| 55 "euc-jp-html", |
| 56 "ISO_2022,locale=ja,version=0", |
| 57 "shift_jis-html", |
| 58 "euc-kr-html", |
| 59 "ISO-2022-KR", |
| 60 "ISO-2022-CN", |
| 61 "ISO-2022-CN-EXT", |
| 62 "HZ-GB-2312" |
| 63 } |
| 64 }; |
| 65 |
| 66 // Entry point for LibFuzzer. |
| 67 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 68 auto rng = CreateRng(data, size); |
| 69 icu::UnicodeString str(reinterpret_cast<const char*>(data), size, |
| 70 kConverters[rng() % kConverters.size()]); |
| 71 return 0; |
| 72 } |
OLD | NEW |