revlog: ensure that flags do not overflow 2 bytes
authorCotizo Sima <cotizo@fb.com>
Mon, 28 Nov 2016 04:34:01 -0800
changeset 30543 03fae9048fa1
parent 30542 64b55bffc1c0
child 30544 d4035372db8d
revlog: ensure that flags do not overflow 2 bytes This patch adds a line that ensures we are not setting by mistake a set of flags overlfowing the 2 bytes they are allocated. Given the way the data is packed in the revlog header, overflowing 2 bytes will result in setting a wrong offset.
mercurial/revlog.py
--- a/mercurial/revlog.py	Sun Nov 27 20:44:52 2016 -0500
+++ b/mercurial/revlog.py	Mon Nov 28 04:34:01 2016 -0800
@@ -72,6 +72,8 @@
     return int(q & 0xFFFF)
 
 def offset_type(offset, type):
+    if (type & ~REVIDX_KNOWN_FLAGS) != 0:
+        raise ValueError('unknown revlog index flags')
     return long(long(offset) << 16 | type)
 
 _nullhash = hashlib.sha1(nullid)