Browse Source

Merge "testMaliciousPathEmpty fails on Windows"

stable-3.2
Christian Halstrick 11 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
b686fa45b6
  1. 11
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java
  2. 5
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java

11
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java

@ -54,6 +54,7 @@ import org.eclipse.jgit.util.SystemReader;
import org.junit.Test;
public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase {
protected ObjectId theHead;
protected ObjectId theMerge;
@ -230,8 +231,14 @@ public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase {
}
@Test
public void testMaliciousPathEmpty() throws Exception {
((MockSystemReader) SystemReader.getInstance()).setCurrentPlatform();
public void testMaliciousPathEmptyUnix() throws Exception {
((MockSystemReader) SystemReader.getInstance()).setUnix();
testMaliciousPathBadFirstCheckout("", "no");
}
@Test
public void testMaliciousPathEmptyWindows() throws Exception {
((MockSystemReader) SystemReader.getInstance()).setWindows();
testMaliciousPathBadFirstCheckout("", "no");
}

5
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java vendored

@ -1202,8 +1202,9 @@ public class DirCacheCheckout {
// Space or period at end of file name is ignored by Windows.
// Treat this as a bad path for now. We may want to handle
// this as case insensitivity in the future.
if (raw[ptr - 1] == '.' || raw[ptr - 1] == ' ')
return false;
if (ptr > 0)
if (raw[ptr - 1] == '.' || raw[ptr - 1] == ' ')
return false;
int i;
// Bad names, eliminate suffix first
for (i = start; i < ptr; ++i)

Loading…
Cancel
Save