Loading libs/androidfw/ApkParsing.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,11 @@ const char* ValidLibraryPathLastSlash(const char* fileName, bool suppress64Bit, return nullptr; } // Make sure file starts with 'lib/' prefix. if (strncmp(fileName, APK_LIB.data(), APK_LIB_LEN) != 0) { return nullptr; } // Make sure there aren't subdirectories by checking if the next / after lib/ is the last slash if (memchr(fileName + APK_LIB_LEN, '/', fileNameLen - APK_LIB_LEN) != lastSlash) { return nullptr; Loading libs/androidfw/tests/ApkParsing_test.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,10 @@ TEST(ApkParsingTest, InvalidFileAtRoot) { auto lastSlash = util::ValidLibraryPathLastSlash(path, false, false); ASSERT_THAT(lastSlash, IsNull()); } TEST(ApkParsingTest, InvalidPrefix) { const char* path = "assets/libhello.so"; auto lastSlash = util::ValidLibraryPathLastSlash(path, false, false); ASSERT_THAT(lastSlash, IsNull()); } } No newline at end of file Loading
libs/androidfw/ApkParsing.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,11 @@ const char* ValidLibraryPathLastSlash(const char* fileName, bool suppress64Bit, return nullptr; } // Make sure file starts with 'lib/' prefix. if (strncmp(fileName, APK_LIB.data(), APK_LIB_LEN) != 0) { return nullptr; } // Make sure there aren't subdirectories by checking if the next / after lib/ is the last slash if (memchr(fileName + APK_LIB_LEN, '/', fileNameLen - APK_LIB_LEN) != lastSlash) { return nullptr; Loading
libs/androidfw/tests/ApkParsing_test.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,10 @@ TEST(ApkParsingTest, InvalidFileAtRoot) { auto lastSlash = util::ValidLibraryPathLastSlash(path, false, false); ASSERT_THAT(lastSlash, IsNull()); } TEST(ApkParsingTest, InvalidPrefix) { const char* path = "assets/libhello.so"; auto lastSlash = util::ValidLibraryPathLastSlash(path, false, false); ASSERT_THAT(lastSlash, IsNull()); } } No newline at end of file