diff --git a/backport-mktemp-fix-template-diagnostic-with-suffix.patch b/backport-mktemp-fix-template-diagnostic-with-suffix.patch new file mode 100644 index 0000000000000000000000000000000000000000..4d6e82ed9eccb13ffef7e6c9a5d6cf643916ee66 --- /dev/null +++ b/backport-mktemp-fix-template-diagnostic-with-suffix.patch @@ -0,0 +1,60 @@ +From e397ba1a31b99dbe4460e1aa8124786d487451c1 Mon Sep 17 00:00:00 2001 +From: lvgenggeng +Date: Tue, 27 Feb 2024 09:41:27 +0800 +Subject: [PATCH 1/1] mktemp: fix template diagnostic with --suffix + +* src/mktemp.c (main): When --suffix is specified, TEMPLATE +points to the meraged buffer DEST_NAME. As X's in the suffix are +not significant to the generated random characters, the diagnostic +for too few X's should only refer to the template portion. +* tests/misc/mktemp.pl: Adjust accordingly. +* NEWS: Mention the bug fix. +--- + src/mktemp.c | 10 ++++++++-- + tests/misc/mktemp.pl | 2 +- + 3 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/src/mktemp.c b/src/mktemp.c +index 5f8e5155d..e314ff6e3 100644 +--- a/src/mktemp.c ++++ b/src/mktemp.c +@@ -156,7 +156,7 @@ main (int argc, char **argv) + int status = EXIT_SUCCESS; + size_t x_count; + size_t suffix_len; +- char *dest_name; ++ char *dest_name = nullptr; + + initialize_main (&argc, &argv); + set_program_name (argv[0]); +@@ -255,7 +255,13 @@ main (int argc, char **argv) + } + x_count = count_consecutive_X_s (template, suffix - template); + if (x_count < 3) +- error (EXIT_FAILURE, 0, _("too few X's in template %s"), quote (template)); ++ { ++ /* when suffix was appended to template only diagnose the template. */ ++ if (template == dest_name) ++ template[suffix - template] = '\0'; ++ error (EXIT_FAILURE, 0, _("too few X's in template %s"), ++ quote (template)); ++ } + + if (use_dest_dir) + { +diff --git a/tests/misc/mktemp.pl b/tests/misc/mktemp.pl +index 779fdc63d..95127517b 100755 +--- a/tests/misc/mktemp.pl ++++ b/tests/misc/mktemp.pl +@@ -165,7 +165,7 @@ my @Tests = + ['suffix10f', 'aXXb', {EXIT => 1}, + {ERR=>"$prog: too few X's in template 'aXXb'\n"}], + ['suffix10d', '-d --suffix=X aXX', {EXIT => 1}, +- {ERR=>"$prog: too few X's in template 'aXXX'\n"}], ++ {ERR=>"$prog: too few X's in template 'aXX'\n"}], + + ['suffix11f', '--suffix=.txt', {OUT=>"./tmp.ZZZZZZZZZZ.txt\n"}, + {ENV=>"TMPDIR=."}, +-- +2.20.1 + diff --git a/coreutils.spec b/coreutils.spec index 2d0a0c237a733aed597b8b43fcd3f98c8442bad2..78229c27693810d5f784e897b2abe652eab8854a 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 9.4 -Release: 3 +Release: 4 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -24,6 +24,7 @@ Patch9: backport-coreutils-i18n.patch patch10: backport-CVE-2024-0684-split-do-not-shrink-hold-buffer.patch patch11: test-skip-overlay-filesystem-because-of-no-inotify_add_watch.patch patch12: fix-coredump-if-enable-systemd.patch +patch13: backport-mktemp-fix-template-diagnostic-with-suffix.patch %ifarch sw_64 Patch9001: coreutils-9.0-sw.patch %endif @@ -155,6 +156,9 @@ fi %{_mandir}/man*/* %changelog +* Fri Apr 19 2024 lvgenggeng - 9.4-4 +- add backport-mktemp-fix-template-diagnostic-with-suffix.patch + * Fri Mar 15 2024 xueyamao - 9.4-3 - fix coredump if enable systemd