Skip to content

Commit 06079b6

Browse files
authored
Merge pull request #769 from MarcMil/fix-manifest
Fix ARSC typescount bug and allow disabling of strict mode
2 parents 33823c6 + 4a79a9c commit 06079b6

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

soot-infoflow-android/src/soot/jimple/infoflow/android/resources/ARSCFileParser.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,9 +1481,9 @@ protected static class ResTable_TypeSpec {
14811481
*/
14821482
int res0; // uint8
14831483
/**
1484-
* Must be 1.
1484+
* Specifies the number of ResTable_type entries
14851485
*/
1486-
int res1; // uint16
1486+
int typesCount; // uint16
14871487
/**
14881488
* Number of uint32_t entry configuration masks that follow.
14891489
*/
@@ -1497,7 +1497,7 @@ public int hashCode() {
14971497
result = prime * result + ((header == null) ? 0 : header.hashCode());
14981498
result = prime * result + id;
14991499
result = prime * result + res0;
1500-
result = prime * result + res1;
1500+
result = prime * result + typesCount;
15011501
return result;
15021502
}
15031503

@@ -1521,7 +1521,7 @@ public boolean equals(Object obj) {
15211521
return false;
15221522
if (res0 != other.res0)
15231523
return false;
1524-
if (res1 != other.res1)
1524+
if (typesCount != other.typesCount)
15251525
return false;
15261526
return true;
15271527
}
@@ -2696,10 +2696,8 @@ private int readTypeSpecTable(ResTable_TypeSpec typeSpecTable, byte[] data, int
26962696
}
26972697
offset += 1;
26982698

2699-
typeSpecTable.res1 = readUInt16(data, offset);
2700-
if (typeSpecTable.res1 != 0) {
2701-
raiseFormatViolationIssue("File format violation in type spec table: res1 is not zero", offset);
2702-
}
2699+
//this was reserved before and is now used!
2700+
typeSpecTable.typesCount = readUInt16(data, offset);
27032701
offset += 2;
27042702

27052703
typeSpecTable.entryCount = readUInt32(data, offset);

soot-infoflow-cmd/src/soot/jimple/infoflow/cmd/MainClass.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import soot.jimple.infoflow.android.InfoflowAndroidConfiguration.CallbackAnalyzer;
3434
import soot.jimple.infoflow.android.SetupApplication;
3535
import soot.jimple.infoflow.android.config.XMLConfigurationParser;
36+
import soot.jimple.infoflow.android.resources.ARSCFileParser;
3637
import soot.jimple.infoflow.methodSummary.data.provider.LazySummaryProvider;
3738
import soot.jimple.infoflow.methodSummary.taintWrappers.ReportMissingSummaryWrapper;
3839
import soot.jimple.infoflow.methodSummary.taintWrappers.SummaryTaintWrapper;
@@ -103,6 +104,7 @@ public class MainClass {
103104
private static final String OPTION_MAX_CALLBACKS_DEPTH = "md";
104105
private static final String OPTION_PATH_SPECIFIC_RESULTS = "ps";
105106
private static final String OPTION_MAX_THREAD_NUMBER = "mt";
107+
private static final String OPTION_LENIENT_PARSING_MODE = "lp";
106108

107109
// Inter-component communication
108110
private static final String OPTION_ICC_MODEL = "im";
@@ -249,6 +251,8 @@ private void initializeCommandLineOptions() {
249251
options.addOption(OPTION_CALLGRAPH_FILE, "callgraphdir", true,
250252
"The file in which to store and from which to read serialized callgraphs");
251253
options.addOption(OPTION_CALLGRAPH_ONLY, "callgraphonly", false, "Only compute the callgraph and terminate");
254+
options.addOption(OPTION_LENIENT_PARSING_MODE, "lenientparsing", false,
255+
"Enables non-strict parsing, i.e. tries to continue rather than fail in case of a parsing error");
252256
}
253257

254258
public static void main(String[] args) throws Exception {
@@ -883,6 +887,9 @@ private void parseCommandLineOptions(CommandLine cmd, InfoflowAndroidConfigurati
883887
config.setExcludeSootLibraryClasses(false);
884888
config.setIgnoreFlowsInSystemPackages(false);
885889
}
890+
if (cmd.hasOption(OPTION_LENIENT_PARSING_MODE)) {
891+
ARSCFileParser.STRICT_MODE = false;
892+
}
886893

887894
// Callgraph-specific options
888895
if (cmd.hasOption(OPTION_CALLGRAPH_ONLY))

0 commit comments

Comments
 (0)