From 25effc38ffb60a46024d65a3bb679bcd1dd4016c Mon Sep 17 00:00:00 2001 From: Pawan Wagh Date: Wed, 15 Mar 2023 20:50:36 +0000 Subject: [PATCH] Set sehandle in voldFuzzer Bug: 271649747 Test: m vold_native_service_fuzzer && adb sync && adb shell data/fuzz/x86_64/vold_native_service_fuzzer/vold_native_service_fuzzer Change-Id: I55a17ffd631b0b85e2fc049bffe9a91623699e64 --- tests/VoldFuzzer.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/VoldFuzzer.cpp b/tests/VoldFuzzer.cpp index e91cce8..630a785 100644 --- a/tests/VoldFuzzer.cpp +++ b/tests/VoldFuzzer.cpp @@ -14,15 +14,27 @@ * limitations under the License. */ +#include #include #include "VoldNativeService.h" +#include "sehandle.h" using ::android::fuzzService; using ::android::sp; struct selabel_handle* sehandle; +extern "C" int LLVMFuzzerInitialize(int argc, char argv) { + sehandle = selinux_android_file_context_handle(); + if (!sehandle) { + LOG(ERROR) << "Failed to get SELinux file contexts handle in voldFuzzer!"; + exit(1); + } + selinux_android_set_sehandle(sehandle); + return 0; +} + extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { auto voldService = sp::make(); fuzzService(voldService, FuzzedDataProvider(data, size));