changeset 30552:03fae9048fa1

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.
author Cotizo Sima <cotizo@fb.com>
date Mon, 28 Nov 2016 04:34:01 -0800
parents 64b55bffc1c0
children d4035372db8d
files mercurial/revlog.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)