From c012ae38153dd2fe22243c7c5bc81d6f81568ae1 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Thu, 15 Dec 2016 16:12:39 -0800 Subject: [PATCH] NativeLibraryHelper: Minor fixes Skip over directories when iterating library files. Ensure correct temp file naming. Bug: 33668201 Test: m Test: Device boots Test: Manual: Install debuggable and non-debuggable apps Change-Id: I2f0547e965d9a0c478e333a13b2db02f4eedac2c --- .../com_android_internal_content_NativeLibraryHelper.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index 850c9c6534e9b..f8f9efe2804fb 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -243,7 +243,7 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr return INSTALL_FAILED_INTERNAL_ERROR; } - *(localFileName + nativeLibPath.size()) = '/'; + *(localTmpFileName + nativeLibPath.size()) = '/'; if (strlcpy(localTmpFileName + nativeLibPath.size(), TMP_FILE_PATTERN, TMP_FILE_PATTERN_LEN - nativeLibPath.size()) != TMP_FILE_PATTERN_LEN) { @@ -344,6 +344,11 @@ public: const char* lastSlash = strrchr(fileName, '/'); ALOG_ASSERT(lastSlash != NULL, "last slash was null somehow for %s\n", fileName); + // Skip directories. + if (*(lastSlash + 1) == 0) { + continue; + } + // Make sure the filename is safe. if (!isFilenameSafe(lastSlash + 1)) { continue;