DORMANTno replies

[JGIT PATCH] Make UploadPack capability parsing more liberal

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:46:57
Subsystem: the rest · Maintainer: Linus Torvalds

Prior to 220a6626c86b ("Fix BaseFetchPackConnection's output of
selected capabilities") the JGit pack client produced a capability
request header that JGit itself can't parse, but C Git can.
The parsing error was caused by a missing space after the want'd
SHA-1 and before the first capability name.

Even though JGit's pack client has been fixed in more recent
versions, we should still fix the server to be more libral in
what it accepts from clients, so that older JGit client builds
can still interoperate.

Signed-off-by: Shawn O. Pearce <redacted>
---
 .../src/org/spearce/jgit/transport/UploadPack.java |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java
index fcc1ef7..159bd10 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java
@@ -302,13 +302,13 @@ private void recvWants() throws IOException {
 			if (!line.startsWith("want ") || line.length() < 45)
 				throw new PackProtocolException("expected want; got " + line);
 
-			if (isFirst) {
-				final int sp = line.indexOf(' ', 45);
-				if (sp >= 0) {
-					for (String c : line.substring(sp + 1).split(" "))
-						options.add(c);
-					line = line.substring(0, sp);
-				}
+			if (isFirst && line.length() > 45) {
+				String opt = line.substring(45);
+				if (opt.startsWith(" "))
+					opt = opt.substring(1);
+				for (String c : opt.split(" "))
+					options.add(c);
+				line = line.substring(0, 45);
 			}
 
 			final ObjectId id = ObjectId.fromString(line.substring(5));
-- 
1.6.3.2.406.gd6a466
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help