Skip to content

Commit

Permalink
upgraded the dexlib version, and fixed a severe bug in the dex loader…
Browse files Browse the repository at this point in the history
…. When the multiple_dex option was not enabled, the code loaded the first dex file it could file inside the APK instead of classes.dex. This could lead to the wrong dex file being loaded. Secondly, it indexed all the dex files even when the option was disabled. If the apk contained some broken dex file, this failed the loader.
  • Loading branch information
StevenArzt committed Nov 18, 2016
1 parent e166bbb commit 101a424
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<classpathentry kind="lib" path="libs/powermock-mockito-1.6.1-full.jar"/>
<classpathentry kind="lib" path="libs/jboss-common-core-2.5.0.Final.jar"/>
<classpathentry kind="lib" path="libs/asm-debug-all-5.1.jar"/>
<classpathentry kind="lib" path="libs/dexlib2-2.2b3-55c33ebb.jar"/>
<classpathentry kind="lib" path="libs/util-2.2b3-55c33ebb.jar"/>
<classpathentry kind="lib" path="libs/dexlib2-2.2b4-adb12356.jar"/>
<classpathentry kind="lib" path="libs/util-2.2b4-adb12356.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
4 changes: 2 additions & 2 deletions ant.settings.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ xmlprinter.jar=libs/AXMLPrinter2.jar
## Location of Polyglot classes jar file to link Soot against
polyglot.jar=libs/polyglot.jar

dexlib2.jar=libs/dexlib2-2.2b3-55c33ebb.jar
dexlib-utils.jar=libs/util-2.2b3-55c33ebb.jar
dexlib2.jar=libs/dexlib2-2.2b4-adb12356.jar
dexlib-utils.jar=libs/util-2.2b4-adb12356.jar

slf4j-api.jar=libs/slf4j-api-1.7.5.jar
slf4j-simple.jar=libs/slf4j-simple-1.7.5.jar
Expand Down
4 changes: 2 additions & 2 deletions ant.settings.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ xmlprinter.jar=libs/AXMLPrinter2.jar
## Location of Polyglot classes jar file to link Soot against
polyglot.jar=libs/polyglot.jar

dexlib2.jar=libs/dexlib2-2.1.3-a5d82813.jar
dexlib-utils.jar=libs/util-2.1.3-a5d82813.jar
dexlib2.jar=libs/dexlib2-2.2b4-adb12356.jar
dexlib-utils.jar=libs/util-2.2b4-adb12356.jar

slf4j-api.jar=libs/slf4j-api-1.7.5.jar
slf4j-simple.jar=libs/slf4j-simple-1.7.5.jar
Expand Down
7 changes: 3 additions & 4 deletions src/soot/DexClassProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ private void buildDexIndex(Map<String, File> index, List<String> classPath) {
for (Enumeration<? extends ZipEntry> entries = archive.entries(); entries.hasMoreElements();) {
ZipEntry entry = entries.nextElement();
String entryName = entry.getName();
if(entryName.endsWith(".dex")){
entryNames.add(entryName);
if(!Options.v().process_multiple_dex())
break;
if(entryName.endsWith(".dex")) {
if (Options.v().process_multiple_dex() || entryName.equals("classes.dex"))
entryNames.add(entryName);
}
}
}catch(Exception e){
Expand Down
6 changes: 4 additions & 2 deletions src/soot/SourceLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ private List<String> getClassesUnder(String aPath, String prefix) {
String entryName = entry.getName();
// We are dealing with an apk file
if (entryName.endsWith(".dex"))
classes.addAll(DexClassProvider.classesOfDex(new File(aPath), entryName));
if (Options.v().process_multiple_dex() || entryName.equals("classes.dex"))
classes.addAll(DexClassProvider.classesOfDex(new File(aPath), entryName));
}
} catch (IOException e) {
throw new CompilationDeathException("Error reasing archive '" + aPath + "'",e);
Expand Down Expand Up @@ -294,7 +295,8 @@ else if(entryName.endsWith(".dex")){
if(Options.v().process_multiple_dex()){
for(String dexEntryName : dexEntryNames){
try {
classes.addAll(DexClassProvider.classesOfDex(file,dexEntryName));
classes.addAll(DexClassProvider.classesOfDex(
file,dexEntryName));
} catch (Throwable e) {} /* Ignore unreadable files */
}
}else{
Expand Down
2 changes: 1 addition & 1 deletion src/soot/toDex/DexPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public class DexPrinter {

public DexPrinter() {
int api = Scene.v().getAndroidAPIVersion();
dexFile = DexBuilder.makeDexBuilder(Opcodes.forApi(api));
dexFile = new DexBuilder(Opcodes.forApi(api));
}

private void printApk(String outputDir, File originalApk) throws IOException {
Expand Down

0 comments on commit 101a424

Please sign in to comment.