##// 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 d = readexactly(stream, 4)
23 d = readexactly(stream, 4)
24 l = struct.unpack(">l", d)[0]
24 l = struct.unpack(">l", d)[0]
25 if l <= 4:
25 if l <= 4:
26 if l:
27 raise util.Abort(_("invalid chunk length %d") % l)
26 return ""
28 return ""
27 return readexactly(stream, l - 4)
29 return readexactly(stream, l - 4)
28
30
@@ -149,11 +151,15 b' class unbundle10(object):'
149 return self._stream.close()
151 return self._stream.close()
150
152
151 def chunklength(self):
153 def chunklength(self):
152 d = readexactly(self._stream, 4)
154 d = readexactly(stream, 4)
153 l = max(0, struct.unpack(">l", d)[0] - 4)
155 l = struct.unpack(">l", d)[0]
154 if l and self.callback:
156 if l <= 4:
157 if l:
158 raise util.Abort(_("invalid chunk length %d") % l)
159 return 0
160 if self.callback:
155 self.callback()
161 self.callback()
156 return l
162 return l - 4
157
163
158 def chunk(self):
164 def chunk(self):
159 """return the next chunk from changegroup 'source' as a string"""
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