mirror of
https://github.com/coreutils/coreutils.git
synced 2026-10-28 09:44:34 +08:00
cp: quote directory names when --parents and --verbose are used
* src/cp.c (make_dir_parents_private): Quote the names of the directory and the source. * tests/cp/verbose-parents-quote.sh: New file * tests/local.mk (all_tests): Add the new test. * NEWS: Mention the bug. Discovered by Anthropic's OSS Scanner, as bug ANT-2026-JJG3V3T9.
This commit is contained in:
1 parent
074be5fae5
commit
7d74e197bb
4 files changed
+44
-1
No files matched your search
@@ -20,6 +20,10 @@ GNU coreutils NEWS -*- outline -*-
|
||||
operating on dangling symbolic links.
|
||||
[bug introduced in coreutils-5.3.0]
|
||||
|
||||
'cp --verbose --parents' now quotes the names of the parent directories that
|
||||
it creates and their sources.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
'date -u MMDDhhmm' no longer uses the local time zone's UTC offset when
|
||||
setting the date and time.
|
||||
[bug introduced in coreutils-9.11]
|
||||
|
||||
@@ -580,7 +580,8 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
else
|
||||
{
|
||||
if (verbose_fmt_string != NULL)
|
||||
printf (verbose_fmt_string, src, dir);
|
||||
printf (verbose_fmt_string, quoteaf_n (0, src),
|
||||
quoteaf_n (1, dir));
|
||||
}
|
||||
|
||||
/* We need search and write permissions to the new directory
|
||||
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# Ensure that 'cp --verbose --parents' quotes messages.
|
||||
|
||||
# Copyright (C) 2026 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
||||
print_ver_ cp printf
|
||||
|
||||
NL='
|
||||
'
|
||||
|
||||
mkdir -p a/b"$NL"c b &&
|
||||
echo hello > a/b"$NL"c/f || framework_failure_
|
||||
|
||||
env printf "'a' -> 'b/a'\n"\
|
||||
"%q -> %q\n"\
|
||||
"%q -> %q\n" a/b"$NL"c b/a/b"$NL"c a/b"$NL"c/f b/a/b"$NL"c/f >exp-err \
|
||||
|| framework_failure_
|
||||
|
||||
cp --parents --verbose a/b"$NL"c/f b >out >err || fail=1
|
||||
compare /dev/null out || fail=1
|
||||
compare exp-err err || fail=1
|
||||
|
||||
Exit $fail
|
||||
@@ -615,6 +615,7 @@ all_tests = \
|
||||
tests/cp/no-deref-link3.sh \
|
||||
tests/cp/parent-perm.sh \
|
||||
tests/cp/parent-perm-race.sh \
|
||||
tests/cp/verbose-parents-quote.sh \
|
||||
tests/cp/perm.sh \
|
||||
tests/cp/preserve-2.sh \
|
||||
tests/cp/preserve-link.sh \
|
||||
|
||||
Reference in new issue
Block a user