From a1eaa272b498cac7c6d14f13d65260021836f45a Mon Sep 17 00:00:00 2001 From: glennm Date: Tue, 10 Oct 2000 16:27:22 +0000 Subject: [PATCH] Throws BuildException if it tries to resolve a path which will go further up than the root of the file-system. Reported by: Noris Boyd Patch submitted by: Nico Seessle git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268073 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/Project.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index d1126f0f5..f82dc950d 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -581,7 +581,11 @@ public class Project { while (tok.hasMoreTokens()) { String part = tok.nextToken(); if (part.equals("..")) { - file = new File(file.getParent()); + String parentFile = file.getParent(); + if (parentFile == null) { + throw new BuildException("The file or path you specified (" + fileName + ") is invalid releative to " + baseDir.getAbsolutePath()); + } + file = new File(parentFile); } else if (part.equals(".")) { // Do nothing here } else {