Browse Source

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>
stable-4.3
Chris Gavin 9 years ago committed by Shawn Pearce
parent
commit
d2bf41e7dd
  1. 11
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java

11
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java

@ -161,6 +161,9 @@ class BundleFetchConnection extends BaseFetchConnection {
}
private String readLine(final byte[] hdrbuf) throws IOException {
StringBuilder line = new StringBuilder();
boolean done = false;
while (!done) {
bin.mark(hdrbuf.length);
final int cnt = bin.read(hdrbuf);
int lf = 0;
@ -168,9 +171,13 @@ class BundleFetchConnection extends BaseFetchConnection {
lf++;
bin.reset();
IO.skipFully(bin, lf);
if (lf < cnt && hdrbuf[lf] == '\n')
if (lf < cnt && hdrbuf[lf] == '\n') {
IO.skipFully(bin, 1);
return RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf);
done = true;
}
line.append(RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf));
}
return line.toString();
}
public boolean didFetchTestConnectivity() {

Loading…
Cancel
Save