##// END OF EJS Templates
bundle2: detect and disallow a negative chunk size...
Pierre-Yves David -
r23011:006a81d0 default
parent child Browse files
Show More
@@ -509,6 +509,9 b' class unbundle20(unpackermixin):'
509 self.ui.debug('reading bundle2 stream parameters\n')
509 self.ui.debug('reading bundle2 stream parameters\n')
510 params = {}
510 params = {}
511 paramssize = self._unpack(_fstreamparamsize)[0]
511 paramssize = self._unpack(_fstreamparamsize)[0]
512 if paramssize < 0:
513 raise error.BundleValueError('negative bundle param size: %i'
514 % paramssize)
512 if paramssize:
515 if paramssize:
513 for p in self._readexact(paramssize).split(' '):
516 for p in self._readexact(paramssize).split(' '):
514 p = p.split('=', 1)
517 p = p.split('=', 1)
@@ -558,6 +561,9 b' class unbundle20(unpackermixin):'
558
561
559 returns None if empty"""
562 returns None if empty"""
560 headersize = self._unpack(_fpartheadersize)[0]
563 headersize = self._unpack(_fpartheadersize)[0]
564 if headersize < 0:
565 raise error.BundleValueError('negative part header size: %i'
566 % headersize)
561 self.ui.debug('part header size: %i\n' % headersize)
567 self.ui.debug('part header size: %i\n' % headersize)
562 if headersize:
568 if headersize:
563 return self._readexact(headersize)
569 return self._readexact(headersize)
@@ -765,6 +771,9 b' class unbundlepart(unpackermixin):'
765 payloadsize = self._unpack(_fpayloadsize)[0]
771 payloadsize = self._unpack(_fpayloadsize)[0]
766 self.ui.debug('payload chunk size: %i\n' % payloadsize)
772 self.ui.debug('payload chunk size: %i\n' % payloadsize)
767 while payloadsize:
773 while payloadsize:
774 if payloadsize < 0:
775 msg = 'negative payload chunk size: %i' % payloadsize
776 raise error.BundleValueError(msg)
768 yield self._readexact(payloadsize)
777 yield self._readexact(payloadsize)
769 payloadsize = self._unpack(_fpayloadsize)[0]
778 payloadsize = self._unpack(_fpayloadsize)[0]
770 self.ui.debug('payload chunk size: %i\n' % payloadsize)
779 self.ui.debug('payload chunk size: %i\n' % payloadsize)
General Comments 0
You need to be logged in to leave comments. Login now