[PATCH] revlog: ensure that flags do not overflow 2 bytes

Yuya Nishihara yuya at tcha.org
Sat Nov 26 06:14:15 EST 2016


On Fri, 25 Nov 2016 19:16:23 +0000, Jun Wu wrote:
> Excerpts from Gregory Szorc's message of 2016-11-25 10:59:42 -0800:
> > I think having the check in offset_type() to catch all consumers is the
> > right place. (Another source of the flag is changegroup data via
> > revlog.addgroup() and cg.deltachunk().)
> > 
> > To clarify, I'm suggesting that instead of truncating "type" like this
> > patch is doing, we should raise ValueError in offset_type(). We should
> > never pass in a too large number and IMO this warrants an exception. This
> > will actively prevent bad data from buggy code being written to a revlog.
> 
> +1. I think raising an Exception is better than dropping the bits silently.
> It does not require moving the check elsewhere, but just change "&=" to an
> if condition and raise an RuntimeError or so.

ValueError or assert sounds better. Dropped from patchwork.


More information about the Mercurial-devel mailing list