Patchwork D8371: manifest: fix yet another 20-byte-hash assumption

login
register
mail settings
Submitter phabricator
Date April 2, 2020, 8:32 p.m.
Message ID <differential-rev-PHID-DREV-lz2tpgth76voby7vmmgq-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46005/
State Superseded
Headers show

Comments

phabricator - April 2, 2020, 8:32 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8371

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -292,8 +292,10 @@ 
                 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")
+        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]