Add fuzzers for ICU4C NDK APIs am: f0828de62b
Original change: https://android-review.googlesource.com/c/platform/external/icu/+/1566099
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I3d6eb6cb95e55d8f6501ce70bdae5604acd932fd
diff --git a/icu4c/source/test/Android.bp b/icu4c/source/test/Android.bp
index 11d0655..35fd0a9 100644
--- a/icu4c/source/test/Android.bp
+++ b/icu4c/source/test/Android.bp
@@ -42,6 +42,16 @@
"libicuctest",
"libicutoolutil",
],
+ target: {
+ android: {
+ cflags: [
+ // Required to link libicuuc_cts_stub
+ "-DANDROID_LINK_SHARED_ICU4C",
+ // Do not set the data directory explicitly on Android because libicuuc has set it.
+ "-DANDROID_USE_ICU_REG",
+ ],
+ },
+ },
}
genrule {
diff --git a/icu4c/source/test/cintltst/Android.bp b/icu4c/source/test/cintltst/Android.bp
index 1e65d4b..629d99a 100644
--- a/icu4c/source/test/cintltst/Android.bp
+++ b/icu4c/source/test/cintltst/Android.bp
@@ -22,9 +22,6 @@
"**/*.cpp",
],
cflags: [
- "-DANDROID_LINK_SHARED_ICU4C",
- // Do not set the data directory explicitly.
- "-DANDROID_USE_ICU_REG",
// Disable some file IO tests to workaround test crashing due to missing data files.
"-DUCONFIG_NO_FILE_IO",
"-DZERO_EXIT_CODE_FOR_FAILURES",
diff --git a/icu4c/source/test/fuzzer/Android.bp b/icu4c/source/test/fuzzer/Android.bp
new file mode 100644
index 0000000..9f06578
--- /dev/null
+++ b/icu4c/source/test/fuzzer/Android.bp
@@ -0,0 +1,133 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ default_visibility: [
+ "//external/icu:__subpackages__",
+ ],
+}
+
+cc_defaults {
+ name: "libicu_fuzzer_defaults",
+ defaults: ["icu_test_defaults"],
+ srcs: [
+ "locale_util.cpp",
+ ],
+ fuzz_config: {
+ componentid: 24949, // Bugs are filed to the "Core library" component
+ hotlists: ["930429"], // The hotlist applied on the bug
+ fuzz_on_haiku_device: true,
+ // Email addresses of users who should be CC'd on bugs.
+ cc: [
+ "vichang@google.com",
+ "g2.corp.android-icu-maintainers@google.com",
+ ],
+ // acknowledged in the Android Security Bulletin for any CVEs found by this fuzz target.
+ acknowledgement: [
+ "Victor Chang of Google",
+ "ICU Contributors of Google",
+ ],
+ },
+}
+
+cc_fuzz {
+ name: "break_iterator_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["break_iterator_fuzzer.cpp"],
+}
+
+cc_fuzz {
+ name: "collator_compare_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["collator_compare_fuzzer.cpp"],
+}
+
+cc_fuzz {
+ name: "collator_rulebased_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["collator_rulebased_fuzzer.cpp"],
+ corpus: ["collator_rulebased_fuzzer_seed_corpus.txt"],
+}
+
+cc_fuzz {
+ name: "converter_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["converter_fuzzer.cpp"],
+}
+
+cc_fuzz {
+ name: "locale_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["locale_fuzzer.cpp"],
+}
+
+cc_fuzz {
+ name: "number_format_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["number_format_fuzzer.cpp"],
+}
+
+cc_fuzz {
+ name: "ucasemap_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["ucasemap_fuzzer.cpp"],
+}
+
+cc_fuzz {
+ name: "uloc_canonicalize_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["uloc_canonicalize_fuzzer.cpp"],
+ corpus: ["uloc_canonicalize_fuzzer_seed_corpus.txt"],
+}
+
+cc_fuzz {
+ name: "uloc_for_language_tag_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["uloc_for_language_tag_fuzzer.cpp"],
+ corpus: ["uloc_for_language_tag_fuzzer_seed_corpus.txt"],
+}
+
+cc_fuzz {
+ name: "uloc_get_name_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["uloc_get_name_fuzzer.cpp"],
+ corpus: ["uloc_get_name_fuzzer_seed_corpus.txt"],
+}
+
+cc_fuzz {
+ name: "uloc_is_right_to_left_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["uloc_is_right_to_left_fuzzer.cpp"],
+ corpus: ["uloc_is_right_to_left_fuzzer_seed_corpus.txt"],
+}
+
+cc_fuzz {
+ name: "uloc_open_keywords_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["uloc_open_keywords_fuzzer.cpp"],
+ corpus: ["uloc_open_keywords_fuzzer_seed_corpus.txt"],
+}
+
+cc_fuzz {
+ name: "unicode_string_codepage_create_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["unicode_string_codepage_create_fuzzer.cpp"],
+}
+
+cc_fuzz {
+ name: "uregex_open_fuzzer",
+ defaults: ["libicu_fuzzer_defaults"],
+ srcs: ["uregex_open_fuzzer.cpp"],
+ dictionary: "uregex_open_fuzzer.dict",
+}
diff --git a/icu4c/source/test/intltest/Android.bp b/icu4c/source/test/intltest/Android.bp
index 8b812f8..3bdd6a4 100644
--- a/icu4c/source/test/intltest/Android.bp
+++ b/icu4c/source/test/intltest/Android.bp
@@ -18,9 +18,6 @@
// Workaround to run primary abi only in CTS
stem: "icu.intltest",
cflags: [
- "-DANDROID_LINK_SHARED_ICU4C",
- // Do not set the data directory explicitly.
- "-DANDROID_USE_ICU_REG",
// Needed for char* shift calculation in the test.
"-Wno-string-plus-int",
"-DZERO_EXIT_CODE_FOR_FAILURES",