From f4596284a092dd3143b4c55704258aa1c47c410b Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Thu, 17 Sep 2015 16:11:39 +0200 Subject: [PATCH] Fix endless loop in ObjectChecker for MacOS Bug: 477090 Change-Id: I0ba416f1cc172a835dd2723ff7fa904597ffd097 Signed-off-by: Matthias Sohn --- .../tst/org/eclipse/jgit/lib/ObjectCheckerTest.java | 11 +++++++++++ .../src/org/eclipse/jgit/lib/ObjectChecker.java | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java index 274757d95..3abe81cf8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java @@ -1809,6 +1809,17 @@ public class ObjectCheckerTest { } } + @Test + public void testBug477090() throws CorruptObjectException { + checker.setSafeForMacOS(true); + final byte[] bytes = { + // U+221E 0xe2889e INFINITY ∞ + (byte) 0xe2, (byte) 0x88, (byte) 0x9e, + // .html + 0x2e, 0x68, 0x74, 0x6d, 0x6c }; + checker.checkPathSegment(bytes, 0, bytes.length); + } + @Test public void testRejectDotAtEndOnWindows() { checker.setSafeForWindows(true); 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 33c65ab04..a7a67a881 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java @@ -618,8 +618,9 @@ public class ObjectChecker { default: return false; } + default: + return false; } - break; case (byte) 0xef: // http://www.utf8-chartable.de/unicode-utf8-table.pl?start=65024 checkTruncatedIgnorableUTF8(raw, ptr, end); // U+FEFF 0xefbbbf ZERO WIDTH NO-BREAK SPACE