# HG changeset patch # User Pierre-Yves David # Date 2020-01-15 14:50:52 # Node ID c7eebdb15139b64e652a5182257bf54be3eb8317 # Parent 2ea6a67ff5029f7c64d06331cdb7034404d44d43 nodemap: never read more than the expected data amount Since we are tracking this number we can use it to detect corrupted rawdata file and to only read the correct amount of data when possible. Differential Revision: https://phab.mercurial-scm.org/D7892 diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py --- a/mercurial/revlogutils/nodemap.py +++ b/mercurial/revlogutils/nodemap.py @@ -45,7 +45,12 @@ def persisted_data(revlog): docket.data_unused = data_unused filename = _rawdata_filepath(revlog, docket) - return docket, revlog.opener.tryread(filename) + data = revlog.opener.tryread(filename) + if len(data) < data_length: + return None + elif len(data) > data_length: + data = data[:data_length] + return docket, data def setup_persistent_nodemap(tr, revlog):