fix: skip files that violate safe filepath
@@ -22,6 +22,9 @@ import brut.androlib.res.AndrolibResources;
import brut.androlib.res.data.ResPackage;
import brut.androlib.res.data.ResTable;
import brut.androlib.res.data.ResUnknownFiles;
+import brut.common.InvalidUnknownFileException;
+import brut.common.RootUnknownFileException;
+import brut.common.TraversalUnknownFileException;
import brut.directory.ExtFile;
import brut.androlib.res.xml.ResXmlPatcher;
import brut.androlib.src.SmaliBuilder;
@@ -663,7 +666,15 @@ public class Androlib {
// loop through unknown files
for (Map.Entry<String,String> unknownFileInfo : files.entrySet()) {
- File inputFile = new File(unknownFileDir, BrutIO.sanitizeUnknownFile(unknownFileDir, unknownFileInfo.getKey()));
+ File inputFile;
+
+ try {
+ inputFile = new File(unknownFileDir, BrutIO.sanitizeUnknownFile(unknownFileDir, unknownFileInfo.getKey()));
+ } catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException exception) {
+ LOGGER.warning(String.format("Skipping file %s (%s)", unknownFileInfo.getKey(), exception.getMessage()));
+ continue;
+ }
+
if (inputFile.isDirectory()) {
continue;
}
