changeset 44705:75f1197db884

manifest: fix yet another 20-byte-hash assumption Differential Revision: https://phab.mercurial-scm.org/D8371
author Augie Fackler <augie@google.com>
date Thu, 02 Apr 2020 16:01:36 -0400
parents 0415a566742a
children ce126b6bea79
files mercurial/manifest.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/manifest.py	Thu Apr 02 15:57:07 2020 -0400
+++ b/mercurial/manifest.py	Thu Apr 02 16:01:36 2020 -0400
@@ -292,8 +292,13 @@
                 b"Manifest values must be a tuple of (node, flags)."
             )
         hashval = value[0]
-        if not isinstance(hashval, bytes) or not 20 <= len(hashval) <= 22:
-            raise TypeError(b"node must be a 20-byte byte string")
+        # hashes are either 20 or 32 bytes (sha1 or its replacement),
+        # and allow one extra byte taht won't be persisted to disk but
+        # is sometimes used in memory.
+        if not isinstance(hashval, bytes) or not (
+            20 <= len(hashval) <= 22 or 32 <= len(hashval) <= 34
+        ):
+            raise TypeError(b"node must be a 20-byte or 32-byte byte string")
         flags = value[1]
         if len(hashval) == 22:
             hashval = hashval[:-1]