aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects/icu/unicode_string_codepage_create_fuzzer.cc
diff options
context:
space:
mode:
authorGravatar Abhishek Arya <inferno@chromium.org>2016-11-29 10:58:16 -0800
committerGravatar Abhishek Arya <inferno@chromium.org>2016-11-29 10:58:31 -0800
commitc03c92cce0b04ba2be95a8ac421c9d41777e8e7d (patch)
treea53a87674514234812f01a4c95208cc4554c6c84 /projects/icu/unicode_string_codepage_create_fuzzer.cc
parentea87305a11ab9654ea315c666f581785a862dcb6 (diff)
parentef765503cb3bbf7d2f82cdf01ccc033f6008ac91 (diff)
Merge branch 'master' of https://github.com/google/oss-fuzz
Diffstat (limited to 'projects/icu/unicode_string_codepage_create_fuzzer.cc')
-rw-r--r--projects/icu/unicode_string_codepage_create_fuzzer.cc73
1 files changed, 73 insertions, 0 deletions
diff --git a/projects/icu/unicode_string_codepage_create_fuzzer.cc b/projects/icu/unicode_string_codepage_create_fuzzer.cc
new file mode 100644
index 00000000..bb0489ca
--- /dev/null
+++ b/projects/icu/unicode_string_codepage_create_fuzzer.cc
@@ -0,0 +1,73 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <algorithm>
+#include <array>
+#include <vector>
+
+#include "fuzzer_utils.h"
+#include "unicode/unistr.h"
+
+// Taken from third_party/icu/source/data/mappings/convrtrs.txt file.
+static const std::array<const char*, 45> kConverters = {
+ {
+ "UTF-8",
+ "utf-16be",
+ "utf-16le",
+ "UTF-32",
+ "UTF-32BE",
+ "UTF-32LE",
+ "ibm866-html",
+ "iso-8859-2-html",
+ "iso-8859-3-html",
+ "iso-8859-4-html",
+ "iso-8859-5-html",
+ "iso-8859-6-html",
+ "iso-8859-7-html",
+ "iso-8859-8-html",
+ "ISO-8859-8-I",
+ "iso-8859-10-html",
+ "iso-8859-13-html",
+ "iso-8859-14-html",
+ "iso-8859-15-html",
+ "iso-8859-16-html",
+ "koi8-r-html",
+ "koi8-u-html",
+ "macintosh-html",
+ "windows-874-html",
+ "windows-1250-html",
+ "windows-1251-html",
+ "windows-1252-html",
+ "windows-1253-html",
+ "windows-1254-html",
+ "windows-1255-html",
+ "windows-1256-html",
+ "windows-1257-html",
+ "windows-1258-html",
+ "x-mac-cyrillic-html",
+ "windows-936-2000",
+ "gb18030",
+ "big5-html",
+ "euc-jp-html",
+ "ISO_2022,locale=ja,version=0",
+ "shift_jis-html",
+ "euc-kr-html",
+ "ISO-2022-KR",
+ "ISO-2022-CN",
+ "ISO-2022-CN-EXT",
+ "HZ-GB-2312"
+ }
+};
+
+IcuEnvironment* env = new IcuEnvironment();
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ auto rng = CreateRng(data, size);
+ icu::UnicodeString str(reinterpret_cast<const char*>(data), size,
+ kConverters[rng() % kConverters.size()]);
+ return 0;
+}