GNU bug report logs -
#74452
sed -i --follow-symlinks fails in i586 with large paths
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.