changeset 132:8b73dca5db97

Encode the link targets as netstrings also before digesting them
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 02 Jan 2025 20:55:51 +0100
parents 3a18d71d7c50
children cf4fb9a33f94
files cutils/treesum.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/treesum.py	Thu Jan 02 20:52:49 2025 +0100
+++ b/cutils/treesum.py	Thu Jan 02 20:55:51 2025 +0100
@@ -165,7 +165,7 @@
     if not handle_root_logical and os.path.islink(root):
         linktgt = util.fsencode(os.readlink(root))
         linkdgst = algorithm[0]()
-        linkdgst.update(linktgt)
+        linkdgst.update(b"%d:%s," % (len(linktgt), linktgt))
         dir_dgst = algorithm[0]()
         dir_dgst.update(b"1:S,3:./@,")
         dir_dgst.update(linkdgst.digest())
@@ -185,7 +185,7 @@
             if dn.is_symlink and not follow_directory_symlinks:
                 linktgt = util.fsencode(os.readlink(dn.path))
                 linkdgst = algorithm[0]()
-                linkdgst.update(linktgt)
+                linkdgst.update(b"%d:%s," % (len(linktgt), linktgt))
                 dir_dgst.update(b"1:S,%d:%s," % (len(dn.fsname), dn.fsname))
                 dir_dgst.update(linkdgst.digest())
                 opath = "/".join(top) + "/" + dn.name if top else dn.name