diff options
author | Marc Strapetz <marc.strapetz@syntevo.com> | 2017-01-10 16:28:54 +0100 |
---|---|---|
committer | Marc Strapetz <marc.strapetz@syntevo.com> | 2017-01-15 15:05:51 +0100 |
commit | 1c4b3f8c45fe2bbcc0ea6aa9ffee107312b37310 (patch) | |
tree | 19c28b9630d1e6f91542a17b155bb6a31ad36f21 /org.eclipse.jgit/src | |
parent | d3148f9410b071edd4a4c85d2a43d1fa2574b0d2 (diff) | |
download | jgit-1c4b3f8c45fe2bbcc0ea6aa9ffee107312b37310.tar.gz jgit-1c4b3f8c45fe2bbcc0ea6aa9ffee107312b37310.zip |
Fix possible InvalidObjectIdException in ObjectDirectory
ObjectDirectory.getShallowCommits should throw an IOException
instead of an InvalidArgumentException if invalid SHAs are present
in .git/shallow (as this file is usually edited by a human).
Change-Id: Ia3a39d38f7aec4282109c7698438f0795fbec905
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java | 1 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index ada5bf7116..244356c13b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -90,6 +90,7 @@ public class JGitText extends TranslationBundle { /***/ public String badObjectType; /***/ public String badRef; /***/ public String badSectionEntry; + /***/ public String badShallowLine; /***/ public String bareRepositoryNoWorkdirAndIndex; /***/ public String base64InputNotProperlyPadded; /***/ public String baseLengthIncorrect; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java index ea80528518..c4db19a7ea 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java @@ -690,8 +690,14 @@ public class ObjectDirectory extends FileObjectDatabase { final BufferedReader reader = open(shallowFile); try { String line; - while ((line = reader.readLine()) != null) - shallowCommitsIds.add(ObjectId.fromString(line)); + while ((line = reader.readLine()) != null) { + try { + shallowCommitsIds.add(ObjectId.fromString(line)); + } catch (IllegalArgumentException ex) { + throw new IOException(MessageFormat + .format(JGitText.get().badShallowLine, line)); + } + } } finally { reader.close(); } |