mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-22549 Add Fuzzer for TimeZone
This commit is contained in:
parent
e8e19454da
commit
83327fb92c
2 changed files with 42 additions and 0 deletions
|
@ -45,6 +45,7 @@ FUZZER_TARGETS = \
|
|||
number_formatter_fuzzer \
|
||||
relative_date_time_formatter_fuzzer \
|
||||
rule_based_break_iterator_fuzzer \
|
||||
timezone_create_fuzzer \
|
||||
ucasemap_fuzzer \
|
||||
uloc_canonicalize_fuzzer \
|
||||
uloc_for_language_tag_fuzzer \
|
||||
|
@ -56,6 +57,7 @@ FUZZER_TARGETS = \
|
|||
uprop_fuzzer \
|
||||
uregex_open_fuzzer \
|
||||
|
||||
|
||||
OBJECTS = $(FUZZER_TARGETS:%=%.o)
|
||||
OBJECTS += fuzzer_driver.o locale_util.o
|
||||
|
||||
|
|
40
icu4c/source/test/fuzzer/timezone_create_fuzzer.cpp
Normal file
40
icu4c/source/test/fuzzer/timezone_create_fuzzer.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
// © 2023 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fuzzer_utils.h"
|
||||
#include "unicode/localpointer.h"
|
||||
#include "unicode/timezone.h"
|
||||
|
||||
IcuEnvironment* env = new IcuEnvironment();
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
|
||||
size_t unistr_size = size/2;
|
||||
std::unique_ptr<char16_t[]> fuzzbuff(new char16_t[unistr_size]);
|
||||
std::memcpy(fuzzbuff.get(), data, unistr_size * 2);
|
||||
icu::UnicodeString fuzzstr(false, fuzzbuff.get(), unistr_size);
|
||||
|
||||
icu::LocalPointer<icu::TimeZone> tz(
|
||||
icu::TimeZone::createTimeZone(fuzzstr));
|
||||
|
||||
icu::TimeZone::getEquivalentID(fuzzstr, size);
|
||||
|
||||
icu::UnicodeString output;
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UBool system;
|
||||
icu::TimeZone::getCanonicalID(fuzzstr, output, system, status);
|
||||
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
icu::TimeZone::getIanaID(fuzzstr, output, status);
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
icu::TimeZone::getWindowsID(fuzzstr, output, status);
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
icu::TimeZone::getRegion(fuzzstr, status);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue