diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java index 14cb52898..6e470c9b2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java @@ -346,15 +346,7 @@ public class ObjectChecker { if (c == '/') throw new CorruptObjectException("name contains '/'"); } - if (thisNameB + 1 == ptr) - throw new CorruptObjectException("zero length name"); - if (raw[thisNameB] == '.') { - final int nameLen = (ptr - 1) - thisNameB; - if (nameLen == 1) - throw new CorruptObjectException("invalid name '.'"); - if (nameLen == 2 && raw[thisNameB + 1] == '.') - throw new CorruptObjectException("invalid name '..'"); - } + checkPathSegment(raw, thisNameB, ptr - 1); if (duplicateName(raw, thisNameB, ptr - 1)) throw new CorruptObjectException("duplicate entry names"); @@ -375,6 +367,19 @@ public class ObjectChecker { } } + private static void checkPathSegment(byte[] raw, int ptr, int end) + throws CorruptObjectException { + if (ptr == end) + throw new CorruptObjectException("zero length name"); + if (raw[ptr] == '.') { + int nameLen = end - ptr; + if (nameLen == 1) + throw new CorruptObjectException("invalid name '.'"); + if (nameLen == 2 && raw[ptr + 1] == '.') + throw new CorruptObjectException("invalid name '..'"); + } + } + /** * Check a blob for errors. *