From 3f280997ba08ade840b55742268335a444e1ea66 Mon Sep 17 00:00:00 2001 From: Lotol Date: Sat, 7 Oct 2023 09:15:16 +0000 Subject: [PATCH] update test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/bundleinstalldhost_fuzzer.cpp. Signed-off-by: Lotol --- .../bundleinstalldhost_fuzzer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/bundleinstalldhost_fuzzer.cpp b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/bundleinstalldhost_fuzzer.cpp index 1c48e22d2..a4faca720 100644 --- a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/bundleinstalldhost_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/bundleinstalldhost_fuzzer.cpp @@ -58,6 +58,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) return 0; } + if (size < OHOS::U32_AT_SIZE) { + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN) { + return 0; + } + char* ch = static_cast(malloc(size + 1)); if (ch == nullptr) { return 0;