Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bf6b7c4 commit 4953e49Copy full SHA for 4953e49
1 file changed
java/ql/test/query-tests/security/CWE-022/semmle/tests/ZipTest.java
@@ -41,4 +41,14 @@ public void m4(ZipEntry entry, File dir) {
41
validate(dir, file);
42
FileOutputStream os = new FileOutputStream(file); // OK
43
}
44
+
45
+ public void m5(ZipEntry entry, File dir) {
46
+ String name = entry.getName();
47
+ File file = new File(dir, name);
48
+ Path absfile = file.toPath().toAbsolutePath().normalize();
49
+ Path absdir = dir.toPath().toAbsolutePath().normalize();
50
+ if (!absfile.startsWith(absdir))
51
+ throw new Exception();
52
+ FileOutputStream os = new FileOutputStream(file); // OK
53
+ }
54
0 commit comments