GNU bug report logs - #74452
sed -i --follow-symlinks fails in i586 with large paths

Previous Next

Package: sed;

Reported by: daniel.garcia <at> suse.com

Date: Thu, 21 Nov 2024 04:25:02 UTC

Severity: normal

To reply to this bug, email your comments to 74452 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#74452; Package sed. (Thu, 21 Nov 2024 04:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to daniel.garcia <at> suse.com:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Thu, 21 Nov 2024 04:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: daniel.garcia <at> suse.com
To: bug-sed <at> gnu.org
Subject: sed -i --follow-symlinks fails in i586 with large paths
Date: Wed, 20 Nov 2024 14:11:23 +0100
I've detected that sed fails when trying to replace in place, following
symlinks in 32 bits architecture.

Steps to reproduce:

 * create a long random path with a file and a relative link:
   mkdir -p /tmp/sed/aaaa[...]
   touch /tmp/sed/aaaa[...]/f1
   ln -s f1 f2
   mv f2 /tmp/sed/aaaa[...]/

Then sed fails when trying to replace:

$ sed -i --follow-symlinks 's/a/a/' /tmp/sed/aaaa[...]/f2 
sed: cannot rename /tmp/sed/aaaa[...]/sed5hPvOi: Not a directory

I've tested this with a full path of 100 chars.

Debugging the code I can see that the problem should be in the
"utils.c:follow_symlink" function, but I was unable to find the exact
reason and a fix.

It should be related to the "if (buf_size <= newlen)" because when it
fails, this is false, "linklen == 0" and the "newlen" value is the length
of the dirname, so it returns the "dirname" of the target link file.




This bug report was last modified 206 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.