[PATCH 1 of 3] changegroup: don't accept streams without proper termination

Mads Kiilerich mads at kiilerich.com
Mon Feb 21 20:38:15 CST 2011


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1298340170 -3600
# Branch stable
# Node ID b02a84ff5b395196bd1d883488c00e2bfe656eb7
# Parent  afc84a879ac8d2e4f1de0107fc4a83df3415480b
changegroup: don't accept streams without proper termination

Streams should be terminated with a zero size changegroup, and read should
never be permitted to return less than requested.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -12,8 +12,6 @@
 def getchunk(source):
     """return the next chunk from changegroup 'source' as a string"""
     d = source.read(4)
-    if not d:
-        return ""
     l = struct.unpack(">l", d)[0]
     if l <= 4:
         return ""
@@ -148,8 +146,6 @@
 
     def chunklength(self):
         d = self.read(4)
-        if not d:
-            return 0
         l = max(0, struct.unpack(">l", d)[0] - 4)
         if l and self.callback:
             self.callback()


More information about the Mercurial-devel mailing list