Profiles: length check on file names

This commit is contained in:
zzz
2016-12-16 18:06:38 +00:00
parent 14a839ebba
commit ce47d4ea68
3 changed files with 28 additions and 1 deletions

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 0;
public final static long BUILD = 1;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -44,6 +44,7 @@ class ProfilePersistenceHelper {
private static final String SUFFIX = ".txt.gz";
private static final String UNCOMPRESSED_SUFFIX = ".txt";
private static final String OLD_SUFFIX = ".dat";
private static final int MIN_NAME_LENGTH = PREFIX.length() + 44 + OLD_SUFFIX.length();
private static final String DIR_PREFIX = "p";
private static final String B64 = Base64.ALPHABET_I2P;
@ -193,6 +194,7 @@ class ProfilePersistenceHelper {
private static class ProfileFilter implements FilenameFilter {
public boolean accept(File dir, String filename) {
return (filename.startsWith(PREFIX) &&
filename.length() >= MIN_NAME_LENGTH &&
(filename.endsWith(SUFFIX) || filename.endsWith(OLD_SUFFIX) || filename.endsWith(UNCOMPRESSED_SUFFIX)));
}
}