##// END OF EJS Templates
changegroup: don't accept odd chunk headers
Mads Kiilerich -
r13458:9f2c407c stable
parent child Browse files
Show More
@@ -23,6 +23,8 b' def getchunk(stream):'
23 23 d = readexactly(stream, 4)
24 24 l = struct.unpack(">l", d)[0]
25 25 if l <= 4:
26 if l:
27 raise util.Abort(_("invalid chunk length %d") % l)
26 28 return ""
27 29 return readexactly(stream, l - 4)
28 30
@@ -149,11 +151,15 b' class unbundle10(object):'
149 151 return self._stream.close()
150 152
151 153 def chunklength(self):
152 d = readexactly(self._stream, 4)
153 l = max(0, struct.unpack(">l", d)[0] - 4)
154 if l and self.callback:
154 d = readexactly(stream, 4)
155 l = struct.unpack(">l", d)[0]
156 if l <= 4:
157 if l:
158 raise util.Abort(_("invalid chunk length %d") % l)
159 return 0
160 if self.callback:
155 161 self.callback()
156 return l
162 return l - 4
157 163
158 164 def chunk(self):
159 165 """return the next chunk from changegroup 'source' as a string"""
General Comments 0
You need to be logged in to leave comments. Login now