Update java/ql/src/Security/CWE/CWE-023/PartialPathTraversalGood.java

Co-authored-by: Jonathan Leitschuh <jonathan.leitschuh@gmail.com>
This commit is contained in:
smehta23
2022-07-01 10:55:58 -04:00
committed by GitHub
parent ebe48ec30a
commit 391dd5b38d

View File

@@ -2,7 +2,7 @@ import java.io.File;
public class PartialPathTraversalGood {
public void example(File dir, File parent) throws IOException {
if (!dir.getCanonicalPath().startsWith(parent.getCanonicalPath().toPath())) {
if (!dir.getCanonicalPath().toPath().startsWith(parent.getCanonicalPath().toPath())) {
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
}
}