Browse Source

Fix possible SIOOBE in RefDirectory.parsePackedRefs

This SIOOBE happens reproducibly when trying to access
a repository containing Cygwin symlinks

Change-Id: I25f103fcc723bac7bfaaeee333a86f11627a92c7
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.6
Marc Strapetz 8 years ago committed by David Pursehouse
parent
commit
c6459a6167
  1. 1
      org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
  2. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
  3. 5
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

1
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties

@ -465,6 +465,7 @@ packDoesNotMatchIndex=Pack {0} does not match index
packedRefsHandleIsStale=packed-refs handle is stale, {0}. retry packedRefsHandleIsStale=packed-refs handle is stale, {0}. retry
packetSizeMustBeAtLeast=packet size {0} must be >= {1} packetSizeMustBeAtLeast=packet size {0} must be >= {1}
packetSizeMustBeAtMost=packet size {0} must be <= {1} packetSizeMustBeAtMost=packet size {0} must be <= {1}
packedRefsCorruptionDetected=packed-refs corruption detected: {0}
packfileCorruptionDetected=Packfile corruption detected: {0} packfileCorruptionDetected=Packfile corruption detected: {0}
packFileInvalid=Pack file invalid: {0} packFileInvalid=Pack file invalid: {0}
packfileIsTruncated=Packfile {0} is truncated. packfileIsTruncated=Packfile {0} is truncated.

1
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java

@ -524,6 +524,7 @@ public class JGitText extends TranslationBundle {
/***/ public String packedRefsHandleIsStale; /***/ public String packedRefsHandleIsStale;
/***/ public String packetSizeMustBeAtLeast; /***/ public String packetSizeMustBeAtLeast;
/***/ public String packetSizeMustBeAtMost; /***/ public String packetSizeMustBeAtMost;
/***/ public String packedRefsCorruptionDetected;
/***/ public String packfileCorruptionDetected; /***/ public String packfileCorruptionDetected;
/***/ public String packFileInvalid; /***/ public String packFileInvalid;
/***/ public String packfileIsTruncated; /***/ public String packfileIsTruncated;

5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

@ -843,6 +843,11 @@ public class RefDirectory extends RefDatabase {
} }
int sp = p.indexOf(' '); int sp = p.indexOf(' ');
if (sp < 0) {
throw new IOException(MessageFormat.format(
JGitText.get().packedRefsCorruptionDetected,
packedRefsFile.getAbsolutePath()));
}
ObjectId id = ObjectId.fromString(p.substring(0, sp)); ObjectId id = ObjectId.fromString(p.substring(0, sp));
String name = copy(p, sp + 1, p.length()); String name = copy(p, sp + 1, p.length());
ObjectIdRef cur; ObjectIdRef cur;

Loading…
Cancel
Save