Re: Patch for inf loop in rcsparse

Michael Haggerty <[email protected]> Tue, 25 Nov 2014 10:01:56 +0100
Newsgroups gmane.comp.version-control.subversion.cvs2svn.devel
Message-ID <[email protected]>
On 11/25/2014 09:59 AM, Michael Haggerty wrote:
> On 11/21/2014 07:29 PM, Linas Vepstas wrote:
>> I tripped over an inf loop in the cvs2svn_rcsparse part of the code.
>> The fix seems to be a simple cut-n-paste of an error check done a few
>> dozen lines earlier.  The patch is:
>>
>>
>> --- a/cvs2svn_rcsparse/default.py.orig    2014-11-21 12:18:02.880417060 -0600
>> +++ b/cvs2svn_rcsparse/default.py    2014-11-21 12:26:59.226222392 -0600
>> @@ -88,6 +88,10 @@ class _TokenStream:
>>
>>          # we stopped at the end of the buffer, so we may have a partial token
>>          buf = self.rcsfile.read(self.CHUNK_SIZE)
>> +        if buf == '':
>> +          # signal EOF by returning None as the token
>> +          del self.buf   # so we fail if get() is called again
>> +          return None
>>          lbuf = len(buf)
>>          idx = end = 0
>>
>> Without this, this particular block gets stuck in an infinite loop.
>> Presumably, this is a rare, data-dependent ocurance ...
> 
> Thanks for the email. Yes, it appears that the bug is triggered when a
> token in an RCS file falls exactly on a CHUNK_SIZE boundary. Since
> CHUNK_SIZE is 100 kb, it is not surprising that nobody has reported this
> problem before.

Actually, thinking about this for a moment more, the bug you saw
probably happens if a token appears exactly at the end of any RCS file
and doesn't have to do with the CHUNK_SIZE. But I think such an RCS file
would be malformed, and *that* is why the bug is rare in practice.

Michael

-- 
Michael Haggerty
[email protected]

------------------------------------------------------
http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=3091818

To unsubscribe from this discussion, e-mail: [[email protected]].