mirror of
https://github.com/coreutils/coreutils.git
synced 2026-10-28 09:44:34 +08:00
cp: quote destination name when preserving ownership on symlinks fails
* src/copy.c (copy_internal): Add a missing quoteaf call. * tests/cp/link-no-deref.sh: Invoke getlimits_ and uses_strace_. Inject an error using 'strace' to verify the name of the destination is quoted in the error message. Discovered by Anthropic's OSS Scanner, as bug ANT-2026-3M3N6L8K.
This commit is contained in:
1 parent
aad192543e
commit
499a55e03d
2 files changed
+18
-1
No files matched your search
+1
-1
@@ -2569,7 +2569,7 @@ skip:
|
||||
&& ! chown_failure_ok (x))
|
||||
{
|
||||
error (0, errno, _("failed to preserve ownership for %s"),
|
||||
dst_name);
|
||||
quoteaf (dst_name));
|
||||
if (x->require_preserve)
|
||||
goto un_backup;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
||||
print_ver_ cp
|
||||
getlimits_
|
||||
uses_strace_
|
||||
|
||||
ln -s no-such-file dangling-slink || framework_failure_
|
||||
|
||||
@@ -26,4 +28,19 @@ ln -s no-such-file dangling-slink || framework_failure_
|
||||
# with link being applied to the dangling symlink.
|
||||
cp --link --no-dereference dangling-slink d2 || fail=1
|
||||
|
||||
NL='
|
||||
'
|
||||
chowns=chown,lchown,fchownat
|
||||
if strace --quiet=all -o /dev/null -P foo \
|
||||
-e inject=$chowns:error=EPERM true 2>/dev/null; then
|
||||
echo "cp: failed to preserve ownership for ''\$'\\n': $ENOSYS" >exp \
|
||||
|| framework_failure_
|
||||
touch file && ln -s file slink || framework_failure_
|
||||
returns_ 1 strace --quiet=all -o /dev/null -P "$NL" \
|
||||
-e inject=$chowns:error=ENOSYS cp -P --preserve=ownership slink "$NL" \
|
||||
>out 2>err || fail=1
|
||||
compare exp err || fail=1
|
||||
compare /dev/null out || fail=1
|
||||
fi
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user