mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Java: Add test for sanitization using toAbsolutePath().
This commit is contained in:
@@ -41,4 +41,14 @@ public class ZipTest {
|
||||
validate(dir, file);
|
||||
FileOutputStream os = new FileOutputStream(file); // OK
|
||||
}
|
||||
|
||||
public void m5(ZipEntry entry, File dir) {
|
||||
String name = entry.getName();
|
||||
File file = new File(dir, name);
|
||||
Path absfile = file.toPath().toAbsolutePath().normalize();
|
||||
Path absdir = dir.toPath().toAbsolutePath().normalize();
|
||||
if (!absfile.startsWith(absdir))
|
||||
throw new Exception();
|
||||
FileOutputStream os = new FileOutputStream(file); // OK
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user