From 690e02aa2c89d6bb79b4127de960c72595983fb8 Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Mon, 14 Nov 2022 19:13:56 +0000 Subject: [PATCH] Make libhardware host_supported This requires dropping a header file and avoiding a missing strlcpy API. Required for host_supported fuzzers that include this lib. Test: libsensorserviceaidl_fuzzer Bug: 205764765 Change-Id: Ib1d2851e915ed87ef2936a044e7a72bab3077f40 --- Android.bp | 4 ++++ hardware.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Android.bp b/Android.bp index e567ccae..7aa3a23c 100644 --- a/Android.bp +++ b/Android.bp @@ -86,6 +86,7 @@ cc_library_shared { header_libs: ["libhardware_headers"], export_header_lib_headers: ["libhardware_headers"], + host_supported: true, recovery_available: true, vendor_available: true, vndk: { @@ -93,6 +94,9 @@ cc_library_shared { support_system_process: true, }, target: { + host: { + exclude_shared_libs: ["libvndksupport"], + }, recovery: { exclude_shared_libs: ["libvndksupport"], }, diff --git a/hardware.c b/hardware.c index 6e72ce9f..d0e91e97 100644 --- a/hardware.c +++ b/hardware.c @@ -30,7 +30,7 @@ #define LOG_TAG "HAL" #include -#if !defined(__ANDROID_RECOVERY__) +#if !defined(__ANDROID_RECOVERY__) && defined(__ANDROID__) #include #endif @@ -97,7 +97,7 @@ static int load(const char *id, */ handle = dlopen(path, RTLD_NOW); } else { -#if defined(__ANDROID_RECOVERY__) +#if defined(__ANDROID_RECOVERY__) || !defined(__ANDROID__) handle = dlopen(path, RTLD_NOW); #else handle = android_load_sphal_library(path, RTLD_NOW); @@ -206,8 +206,13 @@ int hw_get_module_by_class(const char *class_id, const char *inst, if (inst) snprintf(name, PATH_MAX, "%s.%s", class_id, inst); +#if defined(__ANDROID__) else strlcpy(name, class_id, PATH_MAX); +#else + else + snprintf(name, PATH_MAX, "%s", class_id); +#endif /* * Here we rely on the fact that calling dlopen multiple times on