summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorChris Gavin <chris@chrisgavin.me>2016-01-06 15:53:22 +0000
committerShawn Pearce <spearce@spearce.org>2016-01-21 01:14:56 -0500
commitd2bf41e7dd24ad29dc05b19e1d3281c671e503c7 (patch)
tree075eaddcad1fbdd90b13073c04b7b2f3aa8b137d /org.eclipse.jgit
parent7182cb2a2632b947a100ea817d5ffbb10ef479b6 (diff)
downloadjgit-d2bf41e7dd24ad29dc05b19e1d3281c671e503c7.tar.gz
jgit-d2bf41e7dd24ad29dc05b19e1d3281c671e503c7.zip
Fix TransportException when reading bundle
When reading a bundle file, commit messages who's oneline format is longer than 982 characters caused JGit to treat subsequent text in the commit as a SHA, then throw a TransportException because it's not a valid SHA. Now the readLine method will read all the way to the end of the line, not just the first 1024 characters of it. Change-Id: If15b491aa9a1e4fd9b8bbed2dd9e6be47a64ccb7 Signed-off-by: Chris Gavin <chris@chrisgavin.me>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
index e53c04b535..8038fa4d31 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
@@ -161,16 +161,23 @@ class BundleFetchConnection extends BaseFetchConnection {
}
private String readLine(final byte[] hdrbuf) throws IOException {
- bin.mark(hdrbuf.length);
- final int cnt = bin.read(hdrbuf);
- int lf = 0;
- while (lf < cnt && hdrbuf[lf] != '\n')
- lf++;
- bin.reset();
- IO.skipFully(bin, lf);
- if (lf < cnt && hdrbuf[lf] == '\n')
- IO.skipFully(bin, 1);
- return RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf);
+ StringBuilder line = new StringBuilder();
+ boolean done = false;
+ while (!done) {
+ bin.mark(hdrbuf.length);
+ final int cnt = bin.read(hdrbuf);
+ int lf = 0;
+ while (lf < cnt && hdrbuf[lf] != '\n')
+ lf++;
+ bin.reset();
+ IO.skipFully(bin, lf);
+ if (lf < cnt && hdrbuf[lf] == '\n') {
+ IO.skipFully(bin, 1);
+ done = true;
+ }
+ line.append(RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf));
+ }
+ return line.toString();
}
public boolean didFetchTestConnectivity() {