Commit 21ffc57d1b27ae4e3fb726d041e9e4c5f8f1e58e

Nelson Elhage 2018-06-28T05:27:36

Small style tweak, and set an error (cherry picked from commit 895a668e19dc596e7b12ea27724ceb7b68556106)

diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c
index 2377244..d4fbd37 100644
--- a/src/transports/smart_pkt.c
+++ b/src/transports/smart_pkt.c
@@ -402,7 +402,17 @@ int git_pkt_parse_line(
 
 	len = parse_len(line);
 	if (len < 0) {
-		return GIT_ERROR;
+		/*
+		 * If we fail to parse the length, it might be because the
+		 * server is trying to send us the packfile already.
+		 */
+		if (bufflen >= 4 && !git__prefixcmp(line, "PACK")) {
+			giterr_set(GITERR_NET, "unexpected pack file");
+		} else {
+			giterr_set(GITERR_NET, "bad packet length");
+		}
+
+		return -1;
 	}
 
 	/*