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
--- a/mercurial/revlogutils/nodemap.py Wed Jan 15 15:50:43 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py Wed Jan 15 15:50:52 2020 +0100
@@ -45,7 +45,12 @@
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):