aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
diff options
context:
space:
mode:
authorShawn Pearce <sop@google.com>2014-11-25 11:43:32 -0800
committerMatthias Sohn <matthias.sohn@sap.com>2014-12-18 14:48:46 +0100
commit8d36fa343c689d1334ddc1f722c153203c1d13f7 (patch)
treeb9e33c3c41a93bc06b03d170ad72e2c9738c24d9 /org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
parentd547d0c44b061c0d4e59629588b3074d90747e2d (diff)
downloadjgit-8d36fa343c689d1334ddc1f722c153203c1d13f7.tar.gz
jgit-8d36fa343c689d1334ddc1f722c153203c1d13f7.zip
DirCache: Refuse to read files with invalid paths
If the DirCache contains a path that is known to be invalid, refuse to read the DirCache into memory. This avoids confusing errors later if an invalid path read from the DirCache were to be passed into a new DirCacheEntry constructor. Change-Id: Ic033d81e23a5fbd554cc4dff80a232504562ffa8
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
index b6b376ae8a..eef2e6d3c3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
@@ -56,6 +56,7 @@ import java.security.MessageDigest;
import java.text.MessageFormat;
import java.util.Arrays;
+import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
@@ -189,6 +190,16 @@ public class DirCacheEntry {
md.update((byte) 0);
}
+ try {
+ DirCacheCheckout.checkValidPath(toString(path));
+ } catch (InvalidPathException e) {
+ CorruptObjectException p =
+ new CorruptObjectException(e.getMessage());
+ if (e.getCause() != null)
+ p.initCause(e.getCause());
+ throw p;
+ }
+
// Index records are padded out to the next 8 byte alignment
// for historical reasons related to how C Git read the files.
//