[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH]: Fix off-by-one error in xdelta

From: Daniel Berlin <dberlin_at_dberlin.org>
Date: 2005-02-18 23:49:59 CET

If we had a source_len of 1, and a target_len of >1, and source didn't
match target, we would insert copy operations anyway (even though it was
invalid to do so), due to a check that was < instead of <=
(we checked apos + alen < asize, which fails when apos == 0, alen == 1,
and asize == 1).

You only get matches this small when source length % blocksize ==
something small, but >0.

Rather than try to keep that complicated logic in there, which was
basically trying to say "if the copy size is too small, it's not
profitable to use a copy operation", i've simply made it always insert
copies when it finds a match, regardless of match size.
This both fixes the bug, and simplifies the logic.

We can always add some more complex logic back later to decide whether
to insert copy if we find this doesn't work as well as we want in some
way. It's highly unlikely it makes any difference in practice. :)

I also converted the apr_uint32_t's to apr_size_t to match what
svn_txdelta_op actually uses.

I'll commit this in a few hours, giving someone time to pick nits if
they want :)

(Changelog included in patch)

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Fri Feb 18 23:54:27 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.