in java/com/facebook/soloader/ApkSoSource.java [76:133]
protected boolean shouldExtract(ZipEntry ze, String soName) {
String msg = "";
boolean result = false;
String zipPath = ze.getName();
if (soName.equals(mCorruptedLib)) {
mCorruptedLib = null;
msg = String.format("allowing consideration of corrupted lib %s", soName);
result = true;
} else if ((mFlags & PREFER_ANDROID_LIBS_DIRECTORY) == 0) {
msg = "allowing consideration of " + zipPath + ": self-extraction preferred";
result = true;
} else {
boolean validPath = true;
File sysLibFile = new File(mLibDir, soName);
try {
if (!sysLibFile.getCanonicalPath().startsWith(mLibDir.getCanonicalPath())) {
validPath = false;
msg =
String.format(
"not allowing consideration of %s: %s not in lib dir", zipPath, soName);
result = false;
}
} catch (IOException e) {
validPath = false;
result = false;
msg =
String.format(
"not allowing consideration of %s: %s, IOException when constructing path: %s",
zipPath, soName, e.toString());
}
if (validPath) {
if (!sysLibFile.isFile()) {
msg =
String.format(
"allowing consideration of %s: %s not in system lib dir", zipPath, soName);
result = true;
} else {
long sysLibLength = sysLibFile.length();
long apkLibLength = ze.getSize();
if (sysLibLength != apkLibLength) {
msg =
String.format(
"allowing consideration of %s: sysdir file length is %s, but "
+ "the file is %s bytes long in the APK",
sysLibFile, sysLibLength, apkLibLength);
result = true;
} else {
msg = "not allowing consideration of " + zipPath + ": deferring to libdir";
result = false;
}
}
}
}
Log.d(TAG, msg);
return result;
}