Skip to content

Commit d3ea45a

Browse files
committed
ICU-23239 Limit fuzzer test data size to 32K
Avoid timeout on meaningless test
1 parent 892d449 commit d3ea45a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

icu4c/source/test/fuzzer/fuzzer_driver.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
1414

15+
constexpr size_t kFuzzerTestDataSizeLimit = 32 * 1024; // Limit to 32K bytes
16+
1517
int main(int argc, char* argv[])
1618
{
1719
bool show_warning = true;
@@ -52,7 +54,11 @@ int main(int argc, char* argv[])
5254
}
5355
std::ostringstream ostrm;
5456
ostrm << file.rdbuf();
55-
LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t*>(ostrm.str().c_str()), ostrm.str().size());
57+
size_t data_size = ostrm.str().size();
58+
if (data_size > kFuzzerTestDataSizeLimit) {
59+
data_size = kFuzzerTestDataSizeLimit;
60+
}
61+
LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t*>(ostrm.str().c_str()), data_size);
5662

5763
return 0;
5864
}

0 commit comments

Comments
 (0)