Make path to apk compliant with jar url format

Bug: http://b/21726698
Bug: http://b/8076853
Change-Id: I8c1942a98fe3119746b4dc9f60a7ff215ea7009c
This commit is contained in:
Dmitriy Ivanov 2015-06-09 13:46:51 -07:00
parent 26e663d479
commit 524f1f1efe
2 changed files with 6 additions and 6 deletions

View File

@ -1096,11 +1096,11 @@ static int open_library_in_zipfile(const char* const path,
off64_t* file_offset) { off64_t* file_offset) {
TRACE("Trying zip file open from path '%s'", path); TRACE("Trying zip file open from path '%s'", path);
// Treat an '!' character inside a path as the separator between the name // Treat an '!/' separator inside a path as the separator between the name
// of the zip file on disk and the subdirectory to search within it. // of the zip file on disk and the subdirectory to search within it.
// For example, if path is "foo.zip!bar/bas/x.so", then we search for // For example, if path is "foo.zip!/bar/bas/x.so", then we search for
// "bar/bas/x.so" within "foo.zip". // "bar/bas/x.so" within "foo.zip".
const char* separator = strchr(path, '!'); const char* separator = strstr(path, "!/");
if (separator == nullptr) { if (separator == nullptr) {
return -1; return -1;
} }
@ -1114,7 +1114,7 @@ static int open_library_in_zipfile(const char* const path,
buf[separator - path] = '\0'; buf[separator - path] = '\0';
const char* zip_path = buf; const char* zip_path = buf;
const char* file_path = &buf[separator - path + 1]; const char* file_path = &buf[separator - path + 2];
int fd = TEMP_FAILURE_RETRY(open(zip_path, O_RDONLY | O_CLOEXEC)); int fd = TEMP_FAILURE_RETRY(open(zip_path, O_RDONLY | O_CLOEXEC));
if (fd == -1) { if (fd == -1) {
return -1; return -1;

View File

@ -214,7 +214,7 @@ TEST(dlext, android_dlopen_ext_force_load_soname_exception) {
TEST(dlfcn, dlopen_from_zip_absolute_path) { TEST(dlfcn, dlopen_from_zip_absolute_path) {
const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH; const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH;
void* handle = dlopen((lib_path + "!libdir/libdlext_test_fd.so").c_str(), RTLD_NOW); void* handle = dlopen((lib_path + "!/libdir/libdlext_test_fd.so").c_str(), RTLD_NOW);
ASSERT_TRUE(handle != nullptr) << dlerror(); ASSERT_TRUE(handle != nullptr) << dlerror();
int (*fn)(void); int (*fn)(void);
@ -226,7 +226,7 @@ TEST(dlfcn, dlopen_from_zip_absolute_path) {
} }
TEST(dlfcn, dlopen_from_zip_ld_library_path) { TEST(dlfcn, dlopen_from_zip_ld_library_path) {
const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH + "!libdir"; const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH + "!/libdir";
typedef void (*fn_t)(const char*); typedef void (*fn_t)(const char*);
fn_t android_update_LD_LIBRARY_PATH = fn_t android_update_LD_LIBRARY_PATH =