[JGIT PATCH] Make UploadPack capability parsing more liberal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <spearce@xxxxxxxxxxx>
---
 .../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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]