# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1602061007 -19800 # Node ID 225e513c444ef742c16e7436936ed8854e9d23cf # Parent 37c65704869d33223d1e2f750a95308914993ccc tags: add safety check for len(record) while reading hgtagsfnodescache I am trying to fix a breakage where somehow we end up getting a node of 12 length from `getfnode()`. Understanding the hgtagsfnodescache code, it seems highly unlikely that it can happen unless one of `mctx.readfast().get()` or `ctx.filenode()` is returning a node of 12 length. For safety, I think it's better to add a check to make sure that record which we are parsing is of same length we are expecting otherwise we consider that as invalid record. Differential Revision: https://phab.mercurial-scm.org/D9169 diff -r 37c65704869d -r 225e513c444e mercurial/tags.py --- a/mercurial/tags.py Wed Oct 14 17:52:18 2020 +0200 +++ b/mercurial/tags.py Wed Oct 07 14:26:47 2020 +0530 @@ -759,7 +759,7 @@ properprefix = node[0:4] # Validate and return existing entry. - if record != _fnodesmissingrec: + if record != _fnodesmissingrec and len(record) == _fnodesrecsize: fileprefix = record[0:4] if fileprefix == properprefix: