diff options
author | 2024-02-13 16:38:49 +0000 | |
---|---|---|
committer | 2024-02-20 17:43:35 +0000 | |
commit | 8701bf5f321ccad60ee948833fc3208ae6ea51df (patch) | |
tree | 8b0137a386b01bf003b9dccaad2c218542928dc5 /libnativeloader/native_loader.cpp | |
parent | 9414a6383eb60ad0c2b0332e7e066a84413b07f9 (diff) |
Separate handling of a single path and a list of paths when determining
API domains.
Becomes necessary in a later CL where it gets used on more or less
arbitrary paths where we shouldn't treat colons specially.
The old code crashed with a fatal if a list of paths had both vendor
and product directories in it. This changes that to a more appropriate
error that gets propagated to the java level and becomes an exception
where the classloader is created.
Test: atest libnativeloader_test
Bug: 237577392
Change-Id: I783af87a03de18c65fadcd1fd5a71423ec0c786b
Diffstat (limited to 'libnativeloader/native_loader.cpp')
-rw-r--r-- | libnativeloader/native_loader.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index 80af4da502..61925431ef 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -199,6 +199,8 @@ void ResetNativeLoader() { #endif } +// dex_path_j may be a ':'-separated list of paths, e.g. when creating a shared +// library loader - cf. mCodePaths in android.content.pm.SharedLibraryInfo. jstring CreateClassLoaderNamespace(JNIEnv* env, int32_t target_sdk_version, jobject class_loader, @@ -213,13 +215,17 @@ jstring CreateClassLoaderNamespace(JNIEnv* env, ScopedUtfChars dex_path_chars(env, dex_path_j); dex_path = dex_path_chars.c_str(); } - nativeloader::ApiDomain api_domain = nativeloader::GetApiDomainFromPath(dex_path); + + Result<nativeloader::ApiDomain> api_domain = nativeloader::GetApiDomainFromPathList(dex_path); + if (!api_domain.ok()) { + return env->NewStringUTF(api_domain.error().message().c_str()); + } std::lock_guard<std::mutex> guard(g_namespaces_mutex); Result<NativeLoaderNamespace*> ns = CreateClassLoaderNamespaceLocked(env, target_sdk_version, class_loader, - api_domain, + api_domain.value(), is_shared, dex_path, library_path_j, |