diff options
author | Hui Lu <huilu@google.com> | 2013-10-08 16:28:48 -0400 |
---|---|---|
committer | Hui Lu <huilu@google.com> | 2013-10-09 18:46:13 -0400 |
commit | d7f6c65951b540f9ddec3f851e7228c85f07d32d (patch) | |
tree | 3e629ece4b52733496eafe56427271b6b56371b3 /dalvik | |
parent | 918dfa971f17fe3f614adadcd709f424568f50f2 (diff) | |
download | libcore-d7f6c65951b540f9ddec3f851e7228c85f07d32d.zip libcore-d7f6c65951b540f9ddec3f851e7228c85f07d32d.tar.gz libcore-d7f6c65951b540f9ddec3f851e7228c85f07d32d.tar.bz2 |
Remove zip file extension whitelists when validating dex file path.
Just assume a file is either a .dex file or one type of zip files.
Change-Id: I9da778f9cc658295d90b240afddfe5bf5af1edf8
Diffstat (limited to 'dalvik')
-rw-r--r-- | dalvik/src/main/java/dalvik/system/DexPathList.java | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/dalvik/src/main/java/dalvik/system/DexPathList.java b/dalvik/src/main/java/dalvik/system/DexPathList.java index ff0be41..f3bee10 100644 --- a/dalvik/src/main/java/dalvik/system/DexPathList.java +++ b/dalvik/src/main/java/dalvik/system/DexPathList.java @@ -47,9 +47,6 @@ import static libcore.io.OsConstants.*; */ /*package*/ final class DexPathList { private static final String DEX_SUFFIX = ".dex"; - private static final String JAR_SUFFIX = ".jar"; - private static final String ZIP_SUFFIX = ".zip"; - private static final String APK_SUFFIX = ".apk"; /** class definition context */ private final ClassLoader definingContext; @@ -215,34 +212,36 @@ import static libcore.io.OsConstants.*; DexFile dex = null; String name = file.getName(); - if (name.endsWith(DEX_SUFFIX)) { - // Raw dex file (not inside a zip/jar). - try { - dex = loadDexFile(file, optimizedDirectory); - } catch (IOException ex) { - System.logE("Unable to load dex file: " + file, ex); - } - } else if (name.endsWith(APK_SUFFIX) || name.endsWith(JAR_SUFFIX) - || name.endsWith(ZIP_SUFFIX)) { - zip = file; - - try { - dex = loadDexFile(file, optimizedDirectory); - } catch (IOException suppressed) { - /* - * IOException might get thrown "legitimately" by the DexFile constructor if the - * zip file turns out to be resource-only (that is, no classes.dex file in it). - * Let dex == null and hang on to the exception to add to the tea-leaves for - * when findClass returns null. - */ - suppressedExceptions.add(suppressed); - } - } else if (file.isDirectory()) { + if (file.isDirectory()) { // We support directories for looking up resources. // This is only useful for running libcore tests. elements.add(new Element(file, true, null, null)); + } else if (file.isFile()){ + if (name.endsWith(DEX_SUFFIX)) { + // Raw dex file (not inside a zip/jar). + try { + dex = loadDexFile(file, optimizedDirectory); + } catch (IOException ex) { + System.logE("Unable to load dex file: " + file, ex); + } + } else { + zip = file; + + try { + dex = loadDexFile(file, optimizedDirectory); + } catch (IOException suppressed) { + /* + * IOException might get thrown "legitimately" by the DexFile constructor if + * the zip file turns out to be resource-only (that is, no classes.dex file + * in it). + * Let dex == null and hang on to the exception to add to the tea-leaves for + * when findClass returns null. + */ + suppressedExceptions.add(suppressed); + } + } } else { - System.logW("Unknown file type for: " + file); + System.logW("ClassLoader referenced unknown path: " + file); } if ((zip != null) || (dex != null)) { |