Apk.isMediaInstalled() needs to check using sanitized file names
The install process automatically sanitizes filenames to avoid exploits that put attack code in the filename. Media files are also installed using this logic, so the installed check needs to use sanitized file names to be accurate.
This commit is contained in:
parent
c5a1b11315
commit
7dbf03c435
@ -516,7 +516,7 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
}
|
||||
|
||||
public boolean isMediaInstalled(Context context) {
|
||||
return new File(this.getMediaInstallPath(context), this.apkName).isFile();
|
||||
return new File(this.getMediaInstallPath(context), SanitizedFile.sanitizeFileName(this.apkName)).isFile();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,11 +37,11 @@ public class SanitizedFileTest {
|
||||
|
||||
assertEquals("/tmp/blah/safe", safeSanitized.getAbsolutePath());
|
||||
assertEquals("/tmp/blah/safe-and_bleh.boo", nonEvilSanitized.getAbsolutePath());
|
||||
assertEquals("/tmp/blah/rmetcshadow", evilSanitized.getAbsolutePath());
|
||||
assertEquals("/tmp/blah/rm etcshadow", evilSanitized.getAbsolutePath());
|
||||
|
||||
assertEquals("safe", safeSanitized.getName());
|
||||
assertEquals("safe-and_bleh.boo", nonEvilSanitized.getName());
|
||||
assertEquals("rmetcshadow", evilSanitized.getName());
|
||||
assertEquals("rm etcshadow", evilSanitized.getName());
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user