D10146: enclink: check contents of symlinks not just size in case of fcrypt
cschuhen (Corey Schuhen)
phabricator at mercurial-scm.org
Wed Mar 10 06:18:13 UTC 2021
cschuhen created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Check content of symlinks because st_size may indicate the size of encrypted
data which does not match actual link value.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10146
AFFECTED FILES
mercurial/context.py
mercurial/dirstate.py
CHANGE DETAILS
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1279,7 +1279,12 @@
or size == -2 # other parent
or fn in copymap
):
- madd(fn)
+ if (stat.S_ISLNK(st.st_mode) and size != st.st_size):
+ # issue6456: Size returned may be longer due to
+ # encryption on EXT-4 fscrypt, undecided.
+ ladd(fn)
+ else:
+ madd(fn)
elif (
time != st[stat.ST_MTIME]
and time != st[stat.ST_MTIME] & _rangemask
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -993,8 +993,10 @@
# if file data starts with '\1\n', empty metadata block is
# prepended, which adds 4 bytes to filelog.size().
return self._filelog.cmp(self._filenode, fctx.data())
- if self.size() == fctx.size():
+ if self.size() == fctx.size() or self.flags() == b'l':
# size() matches: need to compare content
+ # issue6456: Always compare symlinks because size can represent
+ # encrypted string for EXT-4 encryption(fscrypt).
return self._filelog.cmp(self._filenode, fctx.data())
# size() differs
To: cschuhen, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list