diff --git a/backport-cat-don-t-trust-st_size-on-proc-files.patch b/backport-cat-don-t-trust-st_size-on-proc-files.patch index ba457f9cec9106b8787bedef8c1db5be5f3ff942..2324d7a2834bebb578de52de3d988be339fd19fb 100644 --- a/backport-cat-don-t-trust-st_size-on-proc-files.patch +++ b/backport-cat-don-t-trust-st_size-on-proc-files.patch @@ -19,12 +19,12 @@ for self-copying. 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/cat.c b/src/cat.c -index ac39a48..14e6dfd 100644 +index 4ed404363..b33faeb35 100644 --- a/src/cat.c +++ b/src/cat.c -@@ -646,9 +646,10 @@ main (int argc, char **argv) +@@ -645,9 +645,10 @@ main (int argc, char **argv) /* Optimal size of i/o operations of output. */ - idx_t outsize = io_blksize (stat_buf); + idx_t outsize = io_blksize (&stat_buf); - /* Device and I-node number of the output. */ + /* Device, I-node number and lazily-acquired flags of the output. */ @@ -34,7 +34,7 @@ index ac39a48..14e6dfd 100644 /* True if the output is a regular file. */ bool out_isreg = S_ISREG (stat_buf.st_mode) != 0; -@@ -702,17 +703,27 @@ main (int argc, char **argv) +@@ -701,17 +702,27 @@ main (int argc, char **argv) fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL); @@ -72,7 +72,7 @@ index ac39a48..14e6dfd 100644 /* Pointer to the input buffer. */ diff --git a/tests/cat/cat-self.sh b/tests/cat/cat-self.sh -index ff2afdc..f412707 100755 +index e0f6455c0..854825def 100755 --- a/tests/cat/cat-self.sh +++ b/tests/cat/cat-self.sh @@ -30,4 +30,24 @@ echo y >doc.end || framework_failure_ @@ -101,5 +101,5 @@ index ff2afdc..f412707 100755 + Exit $fail -- -2.27.0 +2.43.0 diff --git a/backport-head-off_t-not-uintmax_t-for-file-offset.patch b/backport-head-off_t-not-uintmax_t-for-file-offset.patch new file mode 100644 index 0000000000000000000000000000000000000000..421a129d559c3e57bbf64118013f10b67db7f7da --- /dev/null +++ b/backport-head-off_t-not-uintmax_t-for-file-offset.patch @@ -0,0 +1,28 @@ +From 0f9e2719e0dd2366f0381daa832f9415f3162af2 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sat, 10 Aug 2024 18:55:09 -0700 +Subject: [PATCH] head: off_t not uintmax_t for file offset + +* src/head.c (elide_tail_lines_pipe): +Use off_t, not uintmax_t, for a local var that is +a file offset. +--- + src/head.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/head.c b/src/head.c +index 2795ae486..a9155c24c 100644 +--- a/src/head.c ++++ b/src/head.c +@@ -504,7 +504,7 @@ elide_tail_lines_pipe (char const *filename, int fd, uintmax_t n_elide, + size_t nlines; + struct linebuffer *next; + }; +- uintmax_t desired_pos = current_pos; ++ off_t desired_pos = current_pos; + typedef struct linebuffer LBUFFER; + LBUFFER *first, *last, *tmp; + size_t total_lines = 0; /* Total number of newlines in all buffers. */ +-- +2.43.0 + diff --git a/backport-putenv-Don-t-crash-upon-out-of-memory.patch b/backport-putenv-Don-t-crash-upon-out-of-memory.patch new file mode 100644 index 0000000000000000000000000000000000000000..13d132ea41b1d1a1e7f3606aafcdf87ad48f9c14 --- /dev/null +++ b/backport-putenv-Don-t-crash-upon-out-of-memory.patch @@ -0,0 +1,30 @@ +From adb76c754290c328a88438af89e491ece7e6a9c5 Mon Sep 17 00:00:00 2001 +From: Bruno Haible +Date: Thu, 6 Jun 2024 02:24:44 +0200 +Subject: [PATCH] putenv: Don't crash upon out-of-memory. + +* lib/putenv.c (_unsetenv): Handle malloc failure. + +Reference:https://github.com/coreutils/gnulib/commit/adb76c754290c328a88438af89e491ece7e6a9c5 +Conflict:delete ChangeLog + +--- + lib/putenv.c | 2 ++ + 1 files changed, 2 insertions(+) + +diff --git a/lib/putenv.c b/lib/putenv.c +index 525d12ae..1d70717e 100644 +--- a/lib/putenv.c ++++ b/lib/putenv.c +@@ -92,6 +92,8 @@ _unsetenv (const char *name) + { + int putenv_result; + char *name_ = malloc (len + 2); ++ if (name_ == NULL) ++ return -1; + memcpy (name_, name, len); + name_[len] = '='; + name_[len + 1] = 0; +-- +2.43.0 + diff --git a/backport-shuf-avoid-integer-overflow-on-huge-inputs.patch b/backport-shuf-avoid-integer-overflow-on-huge-inputs.patch new file mode 100644 index 0000000000000000000000000000000000000000..7d02db5a9697788261c43def876cac5817a4e880 --- /dev/null +++ b/backport-shuf-avoid-integer-overflow-on-huge-inputs.patch @@ -0,0 +1,52 @@ +From 1ea7255f8b0661cdfabbd13f8f443f81665a07e0 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sat, 3 Aug 2024 22:59:12 -0700 +Subject: [PATCH] shuf: avoid integer overflow on huge inputs + +* gl/lib/randperm.c: Include . +(randperm_bound): Return SIZE_MAX if the multiplication overflows. +Do not overflow when converting bit count to byte count. + +Reference:https://github.com/coreutils/coreutils/commit/1ea7255f8b0661cdfabbd13f8f443f81665a07e0 +Conflict:change gl/lib/randperm.c to lib/randperm.c; Adaptation to floor_lg() + +--- + gl/lib/randperm.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/lib/randperm.c b/lib/randperm.c +index 50328cd9a..14a304524 100644 +--- a/lib/randperm.c ++++ b/lib/randperm.c +@@ -23,6 +23,7 @@ + + #include + #include ++#include + #include + + #include "attribute.h" + +@@ -39,13 +40,15 @@ randperm_bound (size_t h, size_t n) + { + /* Upper bound on number of bits needed to generate the first number + of the permutation. */ +- uintmax_t lg_n = floor_lg (n) + 1; ++ unsigned int lg_n = floor_lg (n) + 1; + +- /* Upper bound on number of bits needed to generated the first H elements. */ +- uintmax_t ar = lg_n * h; ++ /* Upper bound on number of bits needed to generate the first H elements. */ ++ uintmax_t ar; ++ if (ckd_mul (&ar, lg_n, h)) ++ return SIZE_MAX; + + /* Convert the bit count to a byte count. */ +- size_t bound = (ar + CHAR_BIT - 1) / CHAR_BIT; ++ size_t bound = ar / CHAR_BIT + (ar % CHAR_BIT != 0); + + return bound; + } +-- +2.43.0 + diff --git a/backport-shuf-fix-randomness-bug.patch b/backport-shuf-fix-randomness-bug.patch new file mode 100644 index 0000000000000000000000000000000000000000..565666ba7b0852fa89b692605be6d6b2e978e22c --- /dev/null +++ b/backport-shuf-fix-randomness-bug.patch @@ -0,0 +1,40 @@ +From bfbb3ec7f798b179d7fa7b42673e068b18048899 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Sat, 3 Aug 2024 22:31:20 -0700 +Subject: [PATCH] shuf: fix randomness bug + +Problem reported by Daniel Carpenter . +* gl/lib/randread.c (randread_new): Fill the ISAAC buffer +instead of storing at most BYTES_BOUND bytes into it. +--- + gl/lib/randread.c | 12 +++++++++++- + 1 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/lib/randread.c b/lib/randread.c +index cbee224bb..43c0cf09f 100644 +--- a/lib/randread.c ++++ b/lib/randread.c +@@ -189,9 +189,19 @@ randread_new (char const *name, size_t bytes_bound) + setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound)); + else + { ++ /* Fill the ISAAC buffer. Although it is tempting to read at ++ most BYTES_BOUND bytes, this is incorrect for two reasons. ++ First, BYTES_BOUND is just an estimate. ++ Second, even if the estimate is correct ++ ISAAC64 poorly randomizes when BYTES_BOUND is small ++ and just the first few bytes of s->buf.isaac.state.m ++ are random while the other bytes are all zero. See: ++ Aumasson J-P. On the pseudo-random generator ISAAC. ++ Cryptology ePrint Archive. 2006;438. ++ . */ + s->buf.isaac.buffered = 0; + if (! get_nonce (s->buf.isaac.state.m, +- MIN (sizeof s->buf.isaac.state.m, bytes_bound))) ++ sizeof s->buf.isaac.state.m)) + { + int e = errno; + randread_free_body (s); +-- +2.43.0 + diff --git a/backport-split-don-t-trust-st_size-on-proc-files.patch b/backport-split-don-t-trust-st_size-on-proc-files.patch index 40d12a599d88d4f104d379221cda214de253bd53..dc051b97b1e274308af9967e486221d3e74b79a9 100644 --- a/backport-split-don-t-trust-st_size-on-proc-files.patch +++ b/backport-split-don-t-trust-st_size-on-proc-files.patch @@ -13,11 +13,11 @@ Content-Transfer-Encoding: 8bit 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/split.c b/src/split.c -index a32b2d9..862f94b 100644 +index 037960a59..f82a7f74b 100644 --- a/src/split.c +++ b/src/split.c @@ -489,10 +489,8 @@ create (char const *name) - if (SAME_INODE (in_stat_buf, out_stat_buf)) + if (psame_inode (&in_stat_buf, &out_stat_buf)) error (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"), quoteaf (name)); - bool regularish @@ -30,5 +30,5 @@ index a32b2d9..862f94b 100644 return fd; -- -2.27.0 +2.43.0 diff --git a/coreutils.spec b/coreutils.spec index 9ba46931105af11d1772d4701c45aa360d6ff5b6..2603eef8325dcb7a7aeaffcac36f48c1456e3e94 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 9.5 -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/ @@ -21,10 +21,14 @@ Patch6: backport-coreutils-df-direct.patch Patch7: backport-coreutils-i18n.patch Patch8: test-skip-overlay-filesystem-because-of-no-inotify_add_watch.patch Patch9: coreutils-9.5-gcc14-gnulib-lto.patch -#patch9: backport-sort-don-t-trust-st_size-on-proc-files.patch -#patch10: backport-cat-don-t-trust-st_size-on-proc-files.patch -#patch11: backport-dd-don-t-trust-st_size-on-proc-files.patch -#patch12: backport-split-don-t-trust-st_size-on-proc-files.patch +patch10: backport-sort-don-t-trust-st_size-on-proc-files.patch +patch11: backport-cat-don-t-trust-st_size-on-proc-files.patch +patch12: backport-dd-don-t-trust-st_size-on-proc-files.patch +patch13: backport-split-don-t-trust-st_size-on-proc-files.patch +patch14: backport-putenv-Don-t-crash-upon-out-of-memory.patch +patch15: backport-head-off_t-not-uintmax_t-for-file-offset.patch +patch16: backport-shuf-avoid-integer-overflow-on-huge-inputs.patch +patch17: backport-shuf-fix-randomness-bug.patch Patch9001: coreutils-9.5-sw.patch @@ -154,6 +158,17 @@ popd %{_mandir}/man*/* %changelog +* Wed Sep 11 2024 huyubiao - 9.5-4 +- sync patches from community +- add backport-sort-don-t-trust-st_size-on-proc-files.patch + backport-cat-don-t-trust-st_size-on-proc-files.patch + backport-dd-don-t-trust-st_size-on-proc-files.patch + backport-split-don-t-trust-st_size-on-proc-files.patch + backport-putenv-Don-t-crash-upon-out-of-memory.patch + backport-head-off_t-not-uintmax_t-for-file-offset.patch + backport-shuf-avoid-integer-overflow-on-huge-inputs.patch + backport-shuf-fix-randomness-bug.patch + * Mon Sep 02 2024 Funda Wang - 9.5-3 - Avoids false warnings with GCC 14.2.1 with -flto - rediff sw_64 patch