Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

client: don't assume server response is of length 20

We do not for sure the length; it is safer to use
Protocol.read_pkt_line().

Also, handle HangupException if read_pkt_line() raises it. This happens
when talking to old versions of git-daemon (v1.6.6.1-26-g38a81b4), where
there won't be anything to read.
  • Loading branch information...
commit 31a832600d8f873640dfc9a8afd4b2c59512abd9 1 parent 12e1c54
@rctay rctay authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 dulwich/client.py
View
14 dulwich/client.py
@@ -28,6 +28,7 @@
from dulwich.errors import (
ChecksumMismatch,
+ HangupException,
)
from dulwich.protocol import (
Protocol,
@@ -119,10 +120,15 @@ def send_pack(self, path, determine_wants, generate_pack_contents):
len(objects))
# read the final confirmation sha
- client_sha = self.proto.read(20)
- if not client_sha in (None, "", sha):
- raise ChecksumMismatch(sha, client_sha)
-
+ try:
+ client_sha = self.proto.read_pkt_line()
+ if not client_sha in (None, "", sha):
+ raise ChecksumMismatch(sha, client_sha)
+ except HangupException:
+ # for git-daemon versions before v1.6.6.1-26-g38a81b4, there is
+ # nothing to read; catch this and hide from the user.
+ pass
+
return new_refs
def fetch(self, path, target, determine_wants=None, progress=None):
Please sign in to comment.
Something went wrong with that request. Please try again.