Compare commits
10 Commits
aec9dfab88
...
a31a5141b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a31a5141b5 | ||
|
|
b6bdb7626c | ||
|
|
f86a5c2515 | ||
|
|
e7b405de96 | ||
|
|
61a18d412d | ||
|
|
80b999f39c | ||
|
|
6f08fd0148 | ||
|
|
f8071b6cef | ||
|
|
b0d42ef0d6 | ||
|
|
480ea50f29 |
64
backport-cksum-consistently-validate-length-attributes.patch
Normal file
64
backport-cksum-consistently-validate-length-attributes.patch
Normal file
@ -0,0 +1,64 @@
|
||||
From fea833591ba787b1232d13ac4b985bea1e7601de Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Mon, 4 Mar 2024 16:33:23 +0000
|
||||
Subject: [PATCH] cksum: consistently validate --length attributes
|
||||
|
||||
* src/digest.c (main): Only validate the last used --length
|
||||
for being a multiple of 8.
|
||||
* tests/cksum/b2sum.sh: Add a test case.
|
||||
Fixes https://bugs.gnu.org/69546
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/fea833591ba787b1232d13ac4b985bea1e7601de
|
||||
Conflict:Adapt to src/digest.c. Adapt to tests/misc/b2sum.sh.
|
||||
|
||||
---
|
||||
src/digest.c | 10 +++++-----
|
||||
tests/misc/b2sum.sh | 4 ++++
|
||||
2 files changed, 9 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/digest.c b/src/digest.c
|
||||
index 2dfc877..84e2a6b 100644
|
||||
--- a/src/digest.c
|
||||
+++ b/src/digest.c
|
||||
@@ -1299,11 +1299,6 @@ main (int argc, char **argv)
|
||||
digest_length = xdectoumax (optarg, 0, UINTMAX_MAX, "",
|
||||
_("invalid length"), 0);
|
||||
digest_length_str = optarg;
|
||||
- if (digest_length % 8 != 0)
|
||||
- {
|
||||
- error (0, 0, _("invalid length: %s"), quote (digest_length_str));
|
||||
- die (EXIT_FAILURE, 0, _("length is not a multiple of 8"));
|
||||
- }
|
||||
break;
|
||||
#endif
|
||||
#if !HASH_ALGO_SUM
|
||||
@@ -1374,6 +1369,11 @@ main (int argc, char **argv)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("--length is only supported with --algorithm=blake2b"));
|
||||
# endif
|
||||
+ if (digest_length % 8 != 0)
|
||||
+ {
|
||||
+ error (0, 0, _("invalid length: %s"), quote (digest_length_str));
|
||||
+ error (EXIT_FAILURE, 0, _("length is not a multiple of 8"));
|
||||
+ }
|
||||
if (digest_length > BLAKE2B_MAX_LEN * 8)
|
||||
{
|
||||
error (0, 0, _("invalid length: %s"), quote (digest_length_str));
|
||||
diff --git a/tests/misc/b2sum.sh b/tests/misc/b2sum.sh
|
||||
index 99982ca..3b02ecd 100755
|
||||
--- a/tests/misc/b2sum.sh
|
||||
+++ b/tests/misc/b2sum.sh
|
||||
@@ -59,6 +59,10 @@ printf '%s\n' 'BLAKE2' 'BLAKE2b' 'BLAKE2-' 'BLAKE2(' 'BLAKE2 (' > crash.check \
|
||||
|| framework_failure_
|
||||
returns_ 1 $prog -c crash.check || fail=1
|
||||
|
||||
+# This would fail before coreutil-9.4
|
||||
+# Only validate the last specified, used length
|
||||
+$prog -l 123 -l 128 /dev/null || fail=1
|
||||
+
|
||||
done
|
||||
|
||||
Exit $fail
|
||||
--
|
||||
2.33.0
|
||||
|
||||
189
backport-coreutils-df-direct.patch
Normal file
189
backport-coreutils-df-direct.patch
Normal file
@ -0,0 +1,189 @@
|
||||
From 6e36198f10a2f63b89c89ebb5d5c185b20fb3a63 Mon Sep 17 00:00:00 2001
|
||||
From: Kamil Dudka <kdudka@redhat.com>
|
||||
Date: Mon, 29 Mar 2010 17:20:34 +0000
|
||||
Subject: [PATCH] coreutils-df-direct.patch
|
||||
|
||||
---
|
||||
doc/coreutils.texi | 7 ++++++
|
||||
src/df.c | 34 ++++++++++++++++++++++++++--
|
||||
tests/df/direct.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 94 insertions(+), 2 deletions(-)
|
||||
create mode 100755 tests/df/direct.sh
|
||||
|
||||
Reference: https://src.fedoraproject.org/rpms/coreutils/blob/rawhide/f/coreutils-df-direct.patch
|
||||
Conflict: NA
|
||||
|
||||
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
|
||||
index a507280..400e135 100644
|
||||
--- a/doc/coreutils.texi
|
||||
+++ b/doc/coreutils.texi
|
||||
@@ -11303,6 +11303,13 @@ some systems (notably SunOS), doing this yields more up to date results,
|
||||
but in general this option makes @command{df} much slower, especially when
|
||||
there are many or very busy file systems.
|
||||
|
||||
+@item --direct
|
||||
+@opindex --direct
|
||||
+@cindex direct statfs for a file
|
||||
+Do not resolve mount point and show statistics directly for a file. It can be
|
||||
+especially useful for NFS mount points if there is a boundary between two
|
||||
+storage policies behind the mount point.
|
||||
+
|
||||
@item --total
|
||||
@opindex --total
|
||||
@cindex grand total of file system size, usage and available space
|
||||
diff --git a/src/df.c b/src/df.c
|
||||
index 8f760db..a7385fd 100644
|
||||
--- a/src/df.c
|
||||
+++ b/src/df.c
|
||||
@@ -120,6 +120,9 @@ static bool print_type;
|
||||
/* If true, print a grand total at the end. */
|
||||
static bool print_grand_total;
|
||||
|
||||
+/* If true, show statistics for a file instead of mount point. */
|
||||
+static bool direct_statfs;
|
||||
+
|
||||
/* Grand total data. */
|
||||
static struct fs_usage grand_fsu;
|
||||
|
||||
@@ -247,13 +250,15 @@ enum
|
||||
NO_SYNC_OPTION = CHAR_MAX + 1,
|
||||
SYNC_OPTION,
|
||||
TOTAL_OPTION,
|
||||
- OUTPUT_OPTION
|
||||
+ OUTPUT_OPTION,
|
||||
+ DIRECT_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
{"block-size", required_argument, NULL, 'B'},
|
||||
+ {"direct", no_argument, NULL, DIRECT_OPTION},
|
||||
{"inodes", no_argument, NULL, 'i'},
|
||||
{"human-readable", no_argument, NULL, 'h'},
|
||||
{"si", no_argument, NULL, 'H'},
|
||||
@@ -509,7 +514,10 @@ get_header (void)
|
||||
for (col = 0; col < ncolumns; col++)
|
||||
{
|
||||
char *cell = NULL;
|
||||
- char const *header = _(columns[col]->caption);
|
||||
+ char const *header = (columns[col]->field == TARGET_FIELD
|
||||
+ && direct_statfs)?
|
||||
+ _("File") :
|
||||
+ _(columns[col]->caption);
|
||||
|
||||
if (columns[col]->field == SIZE_FIELD
|
||||
&& (header_mode == DEFAULT_MODE
|
||||
@@ -1397,6 +1405,19 @@ get_point (const char *point, const struct stat *statp)
|
||||
static void
|
||||
get_entry (char const *name, struct stat const *statp)
|
||||
{
|
||||
+ if (direct_statfs)
|
||||
+ {
|
||||
+ char *resolved = canonicalize_file_name (name);
|
||||
+ if (resolved)
|
||||
+ {
|
||||
+ char *mp = find_mount_point (name, statp);
|
||||
+ get_dev (NULL, mp, resolved, NULL, NULL, false, false, NULL, false);
|
||||
+ free(mp);
|
||||
+ free (resolved);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
|
||||
&& get_device (name))
|
||||
return;
|
||||
@@ -1467,6 +1488,7 @@ or all file systems by default.\n\
|
||||
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,\n\
|
||||
'-BM' prints sizes in units of 1,048,576 bytes;\n\
|
||||
see SIZE format below\n\
|
||||
+ --direct show statistics for a file instead of mount point\n\
|
||||
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)\n\
|
||||
-H, --si print sizes in powers of 1000 (e.g., 1.1G)\n\
|
||||
"), stdout);
|
||||
@@ -1557,6 +1579,9 @@ main (int argc, char **argv)
|
||||
xstrtol_fatal (e, oi, c, long_options, optarg);
|
||||
}
|
||||
break;
|
||||
+ case DIRECT_OPTION:
|
||||
+ direct_statfs = true;
|
||||
+ break;
|
||||
case 'i':
|
||||
if (header_mode == OUTPUT_MODE)
|
||||
{
|
||||
@@ -1653,6 +1678,13 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (direct_statfs && show_local_fs)
|
||||
+ {
|
||||
+ error (0, 0, _("options --direct and --local (-l) are mutually "
|
||||
+ "exclusive"));
|
||||
+ usage (EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
if (human_output_opts == -1)
|
||||
{
|
||||
if (posix_format)
|
||||
diff --git a/tests/df/direct.sh b/tests/df/direct.sh
|
||||
new file mode 100755
|
||||
index 0000000..8e4cfb8
|
||||
--- /dev/null
|
||||
+++ b/tests/df/direct.sh
|
||||
@@ -0,0 +1,55 @@
|
||||
+#!/bin/sh
|
||||
+# Ensure "df --direct" works as documented
|
||||
+
|
||||
+# Copyright (C) 2010 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 <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
+print_ver_ df
|
||||
+
|
||||
+df || skip_ "df fails"
|
||||
+
|
||||
+DIR=`pwd` || framework_failure
|
||||
+FILE="$DIR/file"
|
||||
+touch "$FILE" || framework_failure
|
||||
+echo "$FILE" > file_exp || framework_failure
|
||||
+echo "Mounted on" > header_mounted_exp || framework_failure
|
||||
+echo "File" > header_file_exp || framework_failure
|
||||
+
|
||||
+fail=0
|
||||
+
|
||||
+df --portability "$FILE" > df_out || fail=1
|
||||
+df --portability --direct "$FILE" > df_direct_out || fail=1
|
||||
+df --portability --direct --local "$FILE" > /dev/null 2>&1 && fail=1
|
||||
+
|
||||
+# check df header
|
||||
+$AWK '{ if (NR==1) print $6 " " $7; }' df_out > header_mounted_out \
|
||||
+ || framework_failure
|
||||
+$AWK '{ if (NR==1) print $6; }' df_direct_out > header_file_out \
|
||||
+ || framework_failure
|
||||
+compare header_mounted_out header_mounted_exp || fail=1
|
||||
+compare header_file_out header_file_exp || fail=1
|
||||
+
|
||||
+# check df output (without --direct)
|
||||
+$AWK '{ if (NR==2) print $6; }' df_out > file_out \
|
||||
+ || framework_failure
|
||||
+compare file_out file_exp && fail=1
|
||||
+
|
||||
+# check df output (with --direct)
|
||||
+$AWK '{ if (NR==2) print $6; }' df_direct_out > file_out \
|
||||
+ || framework_failure
|
||||
+compare file_out file_exp || fail=1
|
||||
+
|
||||
+Exit $fail
|
||||
58
backport-df-fix-memory-leak.patch
Normal file
58
backport-df-fix-memory-leak.patch
Normal file
@ -0,0 +1,58 @@
|
||||
From fb7579768d688a300c4ac76451e1fc7cad59e3e8 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Mon, 31 Jan 2022 19:52:43 -0800
|
||||
Subject: [PATCH] df: fix memory leak
|
||||
|
||||
* src/df.c (devlist_free): Remove.
|
||||
(filter_mount_list): Free all of devlist, instead of merely
|
||||
the entries in devlist_table.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/fb7579768d688a300c4ac76451e1fc7cad59e3e8
|
||||
Conflict:NA
|
||||
|
||||
---
|
||||
src/df.c | 14 ++++----------
|
||||
1 file changed, 4 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/df.c b/src/df.c
|
||||
index 7d3207807..4b2cfb77a 100644
|
||||
--- a/src/df.c
|
||||
+++ b/src/df.c
|
||||
@@ -710,12 +710,6 @@ devlist_for_dev (dev_t dev)
|
||||
return found->seen_last;
|
||||
}
|
||||
|
||||
-static void
|
||||
-devlist_free (void *p)
|
||||
-{
|
||||
- free (p);
|
||||
-}
|
||||
-
|
||||
/* Filter mount list by skipping duplicate entries.
|
||||
In the case of duplicates - based on the device number - the mount entry
|
||||
with a '/' in its me_devname (i.e., not pseudo name like tmpfs) wins.
|
||||
@@ -736,9 +730,7 @@ filter_mount_list (bool devices_only)
|
||||
mount_list_size++;
|
||||
|
||||
devlist_table = hash_initialize (mount_list_size, NULL,
|
||||
- devlist_hash,
|
||||
- devlist_compare,
|
||||
- devlist_free);
|
||||
+ devlist_hash, devlist_compare, NULL);
|
||||
if (devlist_table == NULL)
|
||||
xalloc_die ();
|
||||
|
||||
@@ -845,7 +837,9 @@ filter_mount_list (bool devices_only)
|
||||
me = device_list->me;
|
||||
me->me_next = mount_list;
|
||||
mount_list = me;
|
||||
- device_list = device_list->next;
|
||||
+ struct devlist *next = device_list->next;
|
||||
+ free (device_list);
|
||||
+ device_list = next;
|
||||
}
|
||||
|
||||
hash_free (devlist_table);
|
||||
--
|
||||
2.33.0
|
||||
|
||||
256
backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch
Normal file
256
backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch
Normal file
@ -0,0 +1,256 @@
|
||||
From 8fe800a06e50be3c905ab1694a2d1bfd6e70be42 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Sat, 10 Aug 2024 22:19:17 -0700
|
||||
Subject: [PATCH] head: fix overflows in elide_tail_bytes_pipe
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Not clear that the overflows could be exploited,
|
||||
but they made the code confusing.
|
||||
* src/head.c (elide_tail_bytes_pipe): Don’t convert uintmax_t
|
||||
to size_t first thing; wait until it’s known the value will fit,
|
||||
and then use idx_t rather than size_t to prefer signed types.
|
||||
Prefer idx_t in nearby code, too.
|
||||
Rename locals n_elide_0 to n_elide (for consistency elsewhere)
|
||||
and n_elide to in_elide.
|
||||
Remove bogus (SIZE_MAX < n_elide + READ_BUFSIZE) test;
|
||||
in the typical case where n_elide’s type was the same as
|
||||
that of SIZE_MAX, the test never succeeded, and in the
|
||||
less-common case where n_elide was wider than size_t,
|
||||
the addition could silently overflow, causing the test
|
||||
to fail when it should succeed. The test is not needed anyway now.
|
||||
Add static asserts to document code assumptions.
|
||||
Redo the ! (n_elide <= HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD) case
|
||||
so that it works with enormous values of n_elide even on
|
||||
32-bit platforms; for example, n_bufs is now uintmax_t not size_t.
|
||||
Simplify by using xpalloc instead of by-hand code.
|
||||
Remove bogus ‘if (rem)’ test, as rem is always nonzero.
|
||||
|
||||
Reference:https://github.com/coreutils/gnulib/commit/adb76c754290c328a88438af89e491ece7e6a9c5
|
||||
Conflict:Adapt static_assert to verify;Context adaptation.
|
||||
|
||||
---
|
||||
src/head.c | 129 ++++++++++++++++++++++++-----------------------------
|
||||
1 file changed, 58 insertions(+), 71 deletions(-)
|
||||
|
||||
diff --git a/src/head.c b/src/head.c
|
||||
index 567c2f5..b32b8a4 100644
|
||||
--- a/src/head.c
|
||||
+++ b/src/head.c
|
||||
@@ -238,17 +238,16 @@ elseek (int fd, off_t offset, int whence, char const *filename)
|
||||
}
|
||||
|
||||
/* For an input file with name FILENAME and descriptor FD,
|
||||
- output all but the last N_ELIDE_0 bytes.
|
||||
+ output all but the last N_ELIDE bytes.
|
||||
If CURRENT_POS is nonnegative, assume that the input file is
|
||||
positioned at CURRENT_POS and that it should be repositioned to
|
||||
just before the elided bytes before returning.
|
||||
Return true upon success.
|
||||
Give a diagnostic and return false upon error. */
|
||||
static bool
|
||||
-elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
+elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide,
|
||||
off_t current_pos)
|
||||
{
|
||||
- size_t n_elide = n_elide_0;
|
||||
uintmax_t desired_pos = current_pos;
|
||||
bool ok = true;
|
||||
|
||||
@@ -266,16 +265,9 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
#endif
|
||||
|
||||
#if HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD < 2 * READ_BUFSIZE
|
||||
- "HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD must be at least 2 * READ_BUFSIZE"
|
||||
+# error "HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD must be at least 2 * READ_BUFSIZE"
|
||||
#endif
|
||||
|
||||
- if (SIZE_MAX < n_elide_0 + READ_BUFSIZE)
|
||||
- {
|
||||
- char umax_buf[INT_BUFSIZE_BOUND (n_elide_0)];
|
||||
- die (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
|
||||
- umaxtostr (n_elide_0, umax_buf));
|
||||
- }
|
||||
-
|
||||
/* Two cases to consider...
|
||||
1) n_elide is small enough that we can afford to double-buffer:
|
||||
allocate 2 * (READ_BUFSIZE + n_elide) bytes
|
||||
@@ -287,11 +279,14 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
CAUTION: do not fail (out of memory) when asked to elide
|
||||
a ridiculous amount, but when given only a small input. */
|
||||
|
||||
+ verify (READ_BUFSIZE <= IDX_MAX);
|
||||
+ verify (HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD <= IDX_MAX - READ_BUFSIZE);
|
||||
if (n_elide <= HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD)
|
||||
{
|
||||
+ idx_t in_elide = n_elide;
|
||||
bool first = true;
|
||||
bool eof = false;
|
||||
- size_t n_to_read = READ_BUFSIZE + n_elide;
|
||||
+ size_t n_to_read = READ_BUFSIZE + in_elide;
|
||||
bool i;
|
||||
char *b[2];
|
||||
b[0] = xnmalloc (2, n_to_read);
|
||||
@@ -311,7 +306,7 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
}
|
||||
|
||||
/* reached EOF */
|
||||
- if (n_read <= n_elide)
|
||||
+ if (n_read <= in_elide)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
@@ -321,7 +316,7 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
}
|
||||
else
|
||||
{
|
||||
- delta = n_elide - n_read;
|
||||
+ delta = in_elide - n_read;
|
||||
}
|
||||
}
|
||||
eof = true;
|
||||
@@ -331,15 +326,15 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
the previous round. */
|
||||
if (! first)
|
||||
{
|
||||
- desired_pos += n_elide - delta;
|
||||
- xwrite_stdout (b[!i] + READ_BUFSIZE, n_elide - delta);
|
||||
+ desired_pos += in_elide - delta;
|
||||
+ xwrite_stdout (b[!i] + READ_BUFSIZE, in_elide - delta);
|
||||
}
|
||||
first = false;
|
||||
|
||||
- if (n_elide < n_read)
|
||||
+ if (in_elide < n_read)
|
||||
{
|
||||
- desired_pos += n_read - n_elide;
|
||||
- xwrite_stdout (b[i], n_read - n_elide);
|
||||
+ desired_pos += n_read - in_elide;
|
||||
+ xwrite_stdout (b[i], n_read - in_elide);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,31 +346,24 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
bytes. Then, for each new buffer we read, also write an old one. */
|
||||
|
||||
bool eof = false;
|
||||
- size_t n_read;
|
||||
- bool buffered_enough;
|
||||
- size_t i, i_next;
|
||||
+ idx_t n_read;
|
||||
char **b = NULL;
|
||||
- /* Round n_elide up to a multiple of READ_BUFSIZE. */
|
||||
- size_t rem = READ_BUFSIZE - (n_elide % READ_BUFSIZE);
|
||||
- size_t n_elide_round = n_elide + rem;
|
||||
- size_t n_bufs = n_elide_round / READ_BUFSIZE + 1;
|
||||
- size_t n_alloc = 0;
|
||||
- size_t n_array_alloc = 0;
|
||||
-
|
||||
- buffered_enough = false;
|
||||
+
|
||||
+ idx_t remainder = n_elide % READ_BUFSIZE;
|
||||
+ /* The number of buffers needed to hold n_elide bytes plus one
|
||||
+ extra buffer. They are allocated lazily, so don't report
|
||||
+ overflow now simply because the number does not fit into idx_t. */
|
||||
+ uintmax_t n_bufs = n_elide / READ_BUFSIZE + (remainder != 0) + 1;
|
||||
+ idx_t n_alloc = 0;
|
||||
+ idx_t n_array_alloc = 0;
|
||||
+
|
||||
+ bool buffered_enough = false;
|
||||
+ idx_t i, i_next;
|
||||
for (i = 0, i_next = 1; !eof; i = i_next, i_next = (i_next + 1) % n_bufs)
|
||||
{
|
||||
if (n_array_alloc == i)
|
||||
- {
|
||||
- /* reallocate between 16 and n_bufs entries. */
|
||||
- if (n_array_alloc == 0)
|
||||
- n_array_alloc = MIN (n_bufs, 16);
|
||||
- else if (n_array_alloc <= n_bufs / 2)
|
||||
- n_array_alloc *= 2;
|
||||
- else
|
||||
- n_array_alloc = n_bufs;
|
||||
- b = xnrealloc (b, n_array_alloc, sizeof *b);
|
||||
- }
|
||||
+ b = xpalloc (b, &n_array_alloc, 1, MIN (n_bufs, PTRDIFF_MAX),
|
||||
+ sizeof *b);
|
||||
|
||||
if (! buffered_enough)
|
||||
{
|
||||
@@ -404,43 +392,42 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
}
|
||||
}
|
||||
|
||||
- /* Output any remainder: rem bytes from b[i] + n_read. */
|
||||
- if (rem)
|
||||
+ /* Output the remainder: rem bytes from b[i] + n_read. */
|
||||
+ idx_t rem = READ_BUFSIZE - remainder;
|
||||
+ if (buffered_enough)
|
||||
{
|
||||
- if (buffered_enough)
|
||||
+ idx_t n_bytes_left_in_b_i = READ_BUFSIZE - n_read;
|
||||
+ desired_pos += rem;
|
||||
+ if (rem < n_bytes_left_in_b_i)
|
||||
{
|
||||
- size_t n_bytes_left_in_b_i = READ_BUFSIZE - n_read;
|
||||
- desired_pos += rem;
|
||||
- if (rem < n_bytes_left_in_b_i)
|
||||
- {
|
||||
- xwrite_stdout (b[i] + n_read, rem);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- xwrite_stdout (b[i] + n_read, n_bytes_left_in_b_i);
|
||||
- xwrite_stdout (b[i_next], rem - n_bytes_left_in_b_i);
|
||||
- }
|
||||
+ xwrite_stdout (b[i] + n_read, rem);
|
||||
}
|
||||
- else if (i + 1 == n_bufs)
|
||||
+ else
|
||||
{
|
||||
- /* This happens when n_elide < file_size < n_elide_round.
|
||||
-
|
||||
- |READ_BUF.|
|
||||
- | | rem |
|
||||
- |---------!---------!---------!---------|
|
||||
- |---- n_elide ---------|
|
||||
- | | x |
|
||||
- | |y |
|
||||
- |---- file size -----------|
|
||||
- | |n_read|
|
||||
- |---- n_elide_round ----------|
|
||||
- */
|
||||
- size_t y = READ_BUFSIZE - rem;
|
||||
- size_t x = n_read - y;
|
||||
- desired_pos += x;
|
||||
- xwrite_stdout (b[i_next], x);
|
||||
+ xwrite_stdout (b[i] + n_read, n_bytes_left_in_b_i);
|
||||
+ xwrite_stdout (b[i_next], rem - n_bytes_left_in_b_i);
|
||||
}
|
||||
}
|
||||
+ else if (i + 1 == n_bufs)
|
||||
+ {
|
||||
+ /* This happens when
|
||||
+ n_elide < file_size < (n_bufs - 1) * READ_BUFSIZE.
|
||||
+
|
||||
+ |READ_BUF.|
|
||||
+ | | rem |
|
||||
+ |---------!---------!---------!---------|
|
||||
+ |---- n_elide----------|
|
||||
+ | | x |
|
||||
+ | |y |
|
||||
+ |---- file size -----------|
|
||||
+ | |n_read|
|
||||
+ |(n_bufs - 1) * READ_BUFSIZE--|
|
||||
+ */
|
||||
+ idx_t y = READ_BUFSIZE - rem;
|
||||
+ idx_t x = n_read - y;
|
||||
+ desired_pos += x;
|
||||
+ xwrite_stdout (b[i_next], x);
|
||||
+ }
|
||||
|
||||
free_mem:
|
||||
for (i = 0; i < n_alloc; i++)
|
||||
--
|
||||
2.33.0
|
||||
|
||||
32
backport-head-off_t-not-uintmax_t-for-file-offset.patch
Normal file
32
backport-head-off_t-not-uintmax_t-for-file-offset.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 0f9e2719e0dd2366f0381daa832f9415f3162af2 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
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.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/0f9e2719e0dd2366f0381daa832f9415f3162af2
|
||||
Conflict:NA
|
||||
|
||||
---
|
||||
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
|
||||
|
||||
53
backport-ls-avoid-triggering-automounts.patch
Normal file
53
backport-ls-avoid-triggering-automounts.patch
Normal file
@ -0,0 +1,53 @@
|
||||
From 85c975df2c25bd799370b04bb294e568e001102f Mon Sep 17 00:00:00 2001
|
||||
From: Rohan Sable <rsable@redhat.com>
|
||||
Date: Mon, 7 Mar 2022 14:14:13 +0000
|
||||
Subject: [PATCH] ls: avoid triggering automounts
|
||||
|
||||
statx() has different defaults wrt automounting
|
||||
compared to stat() or lstat(), so explicitly
|
||||
set the AT_NO_AUTOMOUNT flag to suppress that behavior,
|
||||
and avoid unintended operations or potential errors.
|
||||
|
||||
* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior.
|
||||
* NEWS: Mention the change in behavior.
|
||||
Fixes https://bugs.gnu.org/54286
|
||||
|
||||
Signed-off-by: Rohan Sable <rsable@redhat.com>
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/85c975df2c25bd799370b04bb294e568e001102f
|
||||
Conflict:Context adaptation
|
||||
|
||||
---
|
||||
NEWS | 2 ++
|
||||
src/ls.c | 2 +-
|
||||
2 files changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/NEWS b/NEWS
|
||||
index d1fd1dc..0ce883f 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -30,6 +30,8 @@ GNU coreutils NEWS -*- outline -*-
|
||||
invalid speed arguments. Now they're validated against both the
|
||||
general accepted set, and the system supported set of valid speeds.
|
||||
[This bug was present in "the beginning".]
|
||||
+ ls no longer tries to automount files, reverting to the behavior
|
||||
+ before the statx() call was introduced in coreutils-8.32.
|
||||
|
||||
chmod -v no longer misreports modes of dangling symlinks.
|
||||
[bug introduced in coreutils-5.3.0]
|
||||
diff --git a/src/ls.c b/src/ls.c
|
||||
index 1047801..fe0e9f8 100644
|
||||
--- a/src/ls.c
|
||||
+++ b/src/ls.c
|
||||
@@ -1175,7 +1175,7 @@ do_statx (int fd, char const *name, struct stat *st, int flags,
|
||||
{
|
||||
struct statx stx;
|
||||
bool want_btime = mask & STATX_BTIME;
|
||||
- int ret = statx (fd, name, flags, mask, &stx);
|
||||
+ int ret = statx (fd, name, flags | AT_NO_AUTOMOUNT, mask, &stx);
|
||||
if (ret >= 0)
|
||||
{
|
||||
statx_to_stat (&stx, st);
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
From a46f34bb56d545369a6b1321c2d78ac08b676c06 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Tue, 19 Mar 2024 15:55:18 +0000
|
||||
Subject: [PATCH] maint: basenc: consistently check buffer bounds when encoding
|
||||
|
||||
* src/basenc.c (base16_encode, base2msbf_encode, base2lsbf_encode):
|
||||
Ensure we don't overflow the output buffer, whose length is
|
||||
passed in the OUTLEN parameter. This issue was flagged by clang
|
||||
with -Wunused-but-set-parameter.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/a46f34bb56d545369a6b1321c2d78ac08b676c06
|
||||
Conflict:Adapt to context.
|
||||
|
||||
---
|
||||
src/basenc.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/basenc.c b/src/basenc.c
|
||||
index f4ca872..a3f89da 100644
|
||||
--- a/src/basenc.c
|
||||
+++ b/src/basenc.c
|
||||
@@ -508,12 +508,14 @@ static void
|
||||
base16_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
- while (inlen--)
|
||||
+ while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
*out++ = base16[c >> 4];
|
||||
*out++ = base16[c & 0x0F];
|
||||
++in;
|
||||
+ inlen--;
|
||||
+ outlen -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -784,7 +786,7 @@ inline static void
|
||||
base2msbf_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
- while (inlen--)
|
||||
+ while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -792,6 +794,7 @@ base2msbf_encode (char const *restrict in, idx_t inlen,
|
||||
*out++ = c & 0x80 ? '1' : '0';
|
||||
c <<= 1;
|
||||
}
|
||||
+ inlen--;
|
||||
outlen -= 8;
|
||||
++in;
|
||||
}
|
||||
@@ -801,7 +804,7 @@ inline static void
|
||||
base2lsbf_encode (char const *restrict in, idx_t inlen,
|
||||
char *restrict out, idx_t outlen)
|
||||
{
|
||||
- while (inlen--)
|
||||
+ while (inlen && outlen)
|
||||
{
|
||||
unsigned char c = *in;
|
||||
for (int i = 0; i < 8; i++)
|
||||
@@ -809,6 +812,7 @@ base2lsbf_encode (char const *restrict in, idx_t inlen,
|
||||
*out++ = c & 0x01 ? '1' : '0';
|
||||
c >>= 1;
|
||||
}
|
||||
+ inlen--;
|
||||
outlen -= 8;
|
||||
++in;
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
64
backport-numfmt-don-t-require-a-suffix-with-from-iec-i.patch
Normal file
64
backport-numfmt-don-t-require-a-suffix-with-from-iec-i.patch
Normal file
@ -0,0 +1,64 @@
|
||||
From 6229ac946e6ee36158db1a592279671d79a9737a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Mon, 30 Dec 2024 22:48:14 +0000
|
||||
Subject: [PATCH] numfmt: don't require a suffix with --from=iec-i
|
||||
|
||||
* src/numfmt.c (simple_strtod_human): Only look for 'i'
|
||||
after detecting a suffix.
|
||||
* tests/misc/numfmt.pl: Add a test case.
|
||||
* NEWS: Mention the bug fix.
|
||||
Reported at https://bugs.debian.org/1091758
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/6229ac946e6ee36158db1a592279671d79a9737a
|
||||
Conflict:delete the NEWS.
|
||||
|
||||
---
|
||||
src/numfmt.c | 15 +++++++--------
|
||||
tests/misc/numfmt.pl | 1 +
|
||||
2 files changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/numfmt.c b/src/numfmt.c
|
||||
index a9f9e81c8..99c58aee1 100644
|
||||
--- a/src/numfmt.c
|
||||
+++ b/src/numfmt.c
|
||||
@@ -667,18 +667,17 @@ simple_strtod_human (char const *input_str,
|
||||
devmsg (" Auto-scaling, found 'i', switching to base %d\n",
|
||||
scale_base);
|
||||
}
|
||||
+ else if (allowed_scaling == scale_IEC_I)
|
||||
+ {
|
||||
+ if (**endptr == 'i')
|
||||
+ (*endptr)++;
|
||||
+ else
|
||||
+ return SSE_MISSING_I_SUFFIX;
|
||||
+ }
|
||||
|
||||
*precision = 0; /* Reset, to select precision based on scale. */
|
||||
}
|
||||
|
||||
- if (allowed_scaling == scale_IEC_I)
|
||||
- {
|
||||
- if (**endptr == 'i')
|
||||
- (*endptr)++;
|
||||
- else
|
||||
- return SSE_MISSING_I_SUFFIX;
|
||||
- }
|
||||
-
|
||||
long double multiplier = powerld (scale_base, power);
|
||||
|
||||
devmsg (" suffix power=%d^%d = %Lf\n", scale_base, power, multiplier);
|
||||
diff --git a/tests/misc/numfmt.pl b/tests/misc/numfmt.pl
|
||||
index 94f9ec58e..148d9d80c 100755
|
||||
--- a/tests/misc/numfmt.pl
|
||||
+++ b/tests/misc/numfmt.pl
|
||||
@@ -41,6 +41,7 @@ my @Tests =
|
||||
['4', '--from=auto 1K', {OUT => "1000"}],
|
||||
['5', '--from=auto 1Ki', {OUT => "1024"}],
|
||||
['5.1', '--from=iec-i 1Ki', {OUT => "1024"}],
|
||||
+ ['5.2', '--from=iec-i 1', {OUT => "1"}],
|
||||
|
||||
['6', {IN_PIPE => "1234\n"}, {OUT => "1234"}],
|
||||
['7', '--from=si', {IN_PIPE => "2K\n"}, {OUT => "2000"}],
|
||||
--
|
||||
2.43.0
|
||||
|
||||
66
backport-pinky-fix-string-size-calculation.patch
Normal file
66
backport-pinky-fix-string-size-calculation.patch
Normal file
@ -0,0 +1,66 @@
|
||||
From 3e0d7787e67d4f732298d99eee772fc2631ddfb8 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Sat, 11 Nov 2023 00:17:11 -0800
|
||||
Subject: [PATCH] pinky: fix string size calculation
|
||||
|
||||
* src/pinky.c (count_ampersands): Simplify and return idx_t.
|
||||
(create_fullname): Compute proper destination string size,
|
||||
basically, by adding (ulen - 1) * ampersands rather than ulen *
|
||||
(ampersands - 1). Problem found on CHERI-64.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/3e0d7787e67d4f732298d99eee772fc2631ddfb8
|
||||
Conflict:Adapt to context. Adapt to INT_MULTIPLY_WRAPV.
|
||||
|
||||
---
|
||||
src/pinky.c | 21 +++++++++------------
|
||||
1 file changed, 9 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/pinky.c b/src/pinky.c
|
||||
index 6fea949..501a5b7 100644
|
||||
--- a/src/pinky.c
|
||||
+++ b/src/pinky.c
|
||||
@@ -81,15 +81,12 @@ static struct option const longopts[] =
|
||||
|
||||
/* Count and return the number of ampersands in STR. */
|
||||
|
||||
-static size_t _GL_ATTRIBUTE_PURE
|
||||
+static idx_t _GL_ATTRIBUTE_PURE
|
||||
count_ampersands (char const *str)
|
||||
{
|
||||
- size_t count = 0;
|
||||
- do
|
||||
- {
|
||||
- if (*str == '&')
|
||||
- count++;
|
||||
- } while (*str++);
|
||||
+ idx_t count = 0;
|
||||
+ for (; *str; str++)
|
||||
+ count += *str == '&';
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -102,16 +99,16 @@ count_ampersands (char const *str)
|
||||
static char *
|
||||
create_fullname (char const *gecos_name, char const *user_name)
|
||||
{
|
||||
- size_t rsize = strlen (gecos_name) + 1;
|
||||
+ idx_t rsize = strlen (gecos_name) + 1;
|
||||
char *result;
|
||||
char *r;
|
||||
- size_t ampersands = count_ampersands (gecos_name);
|
||||
+ idx_t ampersands = count_ampersands (gecos_name);
|
||||
|
||||
if (ampersands != 0)
|
||||
{
|
||||
- size_t ulen = strlen (user_name);
|
||||
- size_t product;
|
||||
- if (INT_MULTIPLY_WRAPV (ulen, ampersands - 1, &product)
|
||||
+ idx_t ulen = strlen (user_name);
|
||||
+ ptrdiff_t product;
|
||||
+ if (INT_MULTIPLY_WRAPV (ulen - 1, ampersands, &product)
|
||||
|| INT_ADD_WRAPV (rsize, product, &rsize))
|
||||
xalloc_die ();
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
50
backport-pr-don-t-use-uninitialized-var.patch
Normal file
50
backport-pr-don-t-use-uninitialized-var.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From 81d58df1647ea79c5161f99d8bd241f0c78df729 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Tue, 19 Apr 2022 16:13:55 -0700
|
||||
Subject: [PATCH] =?UTF-8?q?pr:=20don=E2=80=99t=20use=20uninitialized=20var?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Found with -flto and --enable-gcc-warnings.
|
||||
* src/pr.c (getoptarg): Fix misuse of xstrtol, which does not
|
||||
necessarily set tmp_long on errror, and does not set errno in any
|
||||
reliable way. The previous code might access uninitialized
|
||||
storage; on typical platforms this merely causes it to possibly
|
||||
print the wrong diagnostic.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/81d58df1647ea79c5161f99d8bd241f0c78df729
|
||||
Conflict:NA
|
||||
|
||||
---
|
||||
src/pr.c | 13 ++++++++++---
|
||||
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/pr.c b/src/pr.c
|
||||
index 4c17c0050..a8feba9d8 100644
|
||||
--- a/src/pr.c
|
||||
+++ b/src/pr.c
|
||||
@@ -1173,10 +1173,17 @@ getoptarg (char *arg, char switch_char, char *character, int *number)
|
||||
if (*arg)
|
||||
{
|
||||
long int tmp_long;
|
||||
- if (xstrtol (arg, NULL, 10, &tmp_long, "") != LONGINT_OK
|
||||
- || tmp_long <= 0 || INT_MAX < tmp_long)
|
||||
+ strtol_error e = xstrtol (arg, NULL, 10, &tmp_long, "");
|
||||
+ if (e == LONGINT_OK)
|
||||
{
|
||||
- error (0, INT_MAX < tmp_long ? EOVERFLOW : errno,
|
||||
+ if (tmp_long <= 0)
|
||||
+ e = LONGINT_INVALID;
|
||||
+ else if (INT_MAX < tmp_long)
|
||||
+ e = LONGINT_OVERFLOW;
|
||||
+ }
|
||||
+ if (e != LONGINT_OK)
|
||||
+ {
|
||||
+ error (0, e & LONGINT_OVERFLOW ? EOVERFLOW : 0,
|
||||
_("'-%c' extra characters or invalid number in the argument: %s"),
|
||||
switch_char, quote (arg));
|
||||
usage (EXIT_FAILURE);
|
||||
--
|
||||
2.33.0
|
||||
|
||||
30
backport-putenv-Don-t-crash-upon-out-of-memory.patch
Normal file
30
backport-putenv-Don-t-crash-upon-out-of-memory.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From adb76c754290c328a88438af89e491ece7e6a9c5 Mon Sep 17 00:00:00 2001
|
||||
From: Bruno Haible <bruno@clisp.org>
|
||||
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
|
||||
|
||||
43
backport-shuf-avoid-integer-overflow-on-huge-inputs.patch
Normal file
43
backport-shuf-avoid-integer-overflow-on-huge-inputs.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 1ea7255f8b0661cdfabbd13f8f443f81665a07e0 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Sat, 3 Aug 2024 22:59:12 -0700
|
||||
Subject: [PATCH] shuf: avoid integer overflow on huge inputs
|
||||
|
||||
* gl/lib/randperm.c: Include <stdckdint.h>.
|
||||
(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 INT_MULTIPLY_WRAPV() and floor_lg()
|
||||
|
||||
---
|
||||
lib/randperm.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lib/randperm.c b/lib/randperm.c
|
||||
index c01c296..7517884 100644
|
||||
--- a/lib/randperm.c
|
||||
+++ b/lib/randperm.c
|
||||
@@ -53,13 +53,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 (INT_MULTIPLY_WRAPV (lg_n, h, &ar))
|
||||
+ 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
|
||||
|
||||
44
backport-shuf-fix-randomness-bug.patch
Normal file
44
backport-shuf-fix-randomness-bug.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From bfbb3ec7f798b179d7fa7b42673e068b18048899 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Sat, 3 Aug 2024 22:31:20 -0700
|
||||
Subject: [PATCH] shuf: fix randomness bug
|
||||
|
||||
Problem reported by Daniel Carpenter <https://bugs.gnu.org/72445>.
|
||||
* gl/lib/randread.c (randread_new): Fill the ISAAC buffer
|
||||
instead of storing at most BYTES_BOUND bytes into it.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/bfbb3ec7f798b179d7fa7b42673e068b18048899
|
||||
Conflict:delete NEWS and THANKS.in; changelog gl/lib/randread.c to lib/randread.c
|
||||
|
||||
---
|
||||
lib/randread.c | 12 +++++++++++-
|
||||
1 file changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/randread.c b/lib/randread.c
|
||||
index 7124e3d..c99f1a1 100644
|
||||
--- a/lib/randread.c
|
||||
+++ b/lib/randread.c
|
||||
@@ -187,9 +187,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.
|
||||
+ <https://eprint.iacr.org/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 (s);
|
||||
--
|
||||
2.43.0
|
||||
|
||||
32
backport-sort-don-t-trust-st_size-on-proc-files.patch
Normal file
32
backport-sort-don-t-trust-st_size-on-proc-files.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 8ff3903281e03d36dd1aa2a202a56f38af726d91 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Sat, 6 Apr 2024 15:17:14 -0700
|
||||
Subject: [PATCH] =?UTF-8?q?sort:=20don=E2=80=99t=20trust=20st=5Fsize=20on?=
|
||||
=?UTF-8?q?=20/proc=20files?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Problem and fix reported by Takashi Kusumi in:
|
||||
https://bugs.gnu.org/70231
|
||||
* src/sort.c (sort_buffer_size): Don’t trust st_size == 0.
|
||||
---
|
||||
src/sort.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/sort.c b/src/sort.c
|
||||
index e779845..b983ca2 100644
|
||||
--- a/src/sort.c
|
||||
+++ b/src/sort.c
|
||||
@@ -1538,7 +1538,7 @@ sort_buffer_size (FILE *const *fps, size_t nfps,
|
||||
!= 0)
|
||||
sort_die (_("stat failed"), files[i]);
|
||||
|
||||
- if (S_ISREG (st.st_mode))
|
||||
+ if (usable_st_size (&st) && 0 < st.st_size)
|
||||
file_size = st.st_size;
|
||||
else
|
||||
{
|
||||
--
|
||||
2.27.0
|
||||
|
||||
36
backport-sort-fix-debug-buffer-overrun.patch
Normal file
36
backport-sort-fix-debug-buffer-overrun.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From e07161d4af89dbf82311ca396ac0916aa90b7301 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Thu, 16 Jan 2025 09:20:45 -0800
|
||||
Subject: [PATCH] sort: fix --debug buffer overrun
|
||||
|
||||
* src/sort.c (debug_key): Fix undefined behavior when a key ends
|
||||
before it starts. Problem reported by Bruno Haible
|
||||
<https://bugs.gnu.org/75606>.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/e07161d4af89dbf82311ca396ac0916aa90b7301
|
||||
Conflict:NA
|
||||
|
||||
---
|
||||
src/sort.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/sort.c b/src/sort.c
|
||||
index 997566240..0928fd57c 100644
|
||||
--- a/src/sort.c
|
||||
+++ b/src/sort.c
|
||||
@@ -2373,7 +2373,11 @@ debug_key (struct line const *line, struct keyfield const *key)
|
||||
if (key->sword != SIZE_MAX)
|
||||
beg = begfield (line, key);
|
||||
if (key->eword != SIZE_MAX)
|
||||
- lim = limfield (line, key);
|
||||
+ {
|
||||
+ lim = limfield (line, key);
|
||||
+ /* Treat field ends before field starts as empty fields. */
|
||||
+ lim = MAX (beg, lim);
|
||||
+ }
|
||||
|
||||
if ((key->skipsblanks && key->sword == SIZE_MAX)
|
||||
|| key->month || key_numeric (key))
|
||||
--
|
||||
2.43.0
|
||||
|
||||
67
backport-stat-only-automount-with-cached-never.patch
Normal file
67
backport-stat-only-automount-with-cached-never.patch
Normal file
@ -0,0 +1,67 @@
|
||||
From 92cb8427c537f37edd43c5cef1909585201372ab Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Mon, 7 Mar 2022 23:29:20 +0000
|
||||
Subject: [PATCH] stat: only automount with --cached=never
|
||||
|
||||
Revert to the default behavior before the introduction of statx().
|
||||
|
||||
* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never.
|
||||
* doc/coreutils.texi (stat invocation): Mention the automount
|
||||
behavior with --cached=never.
|
||||
* NEWS: Mention the change in behavior.
|
||||
|
||||
Fixes https://bugs.gnu.org/54287
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/92cb8427c537f37edd43c5cef1909585201372ab
|
||||
Conflict:Context adaptation
|
||||
|
||||
---
|
||||
NEWS | 4 ++++
|
||||
doc/coreutils.texi | 1 +
|
||||
src/stat.c | 3 +++
|
||||
3 files changed, 8 insertions(+)
|
||||
|
||||
diff --git a/NEWS b/NEWS
|
||||
index 0076273..91c78df 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -6,6 +6,10 @@ GNU coreutils NEWS -*- outline -*-
|
||||
ls no longer tries to automount files, reverting to the behavior
|
||||
before the statx() call was introduced in coreutils-8.32.
|
||||
|
||||
+ stat no longer tries to automount files by default, reverting to the
|
||||
+ behavior before the statx() call was introduced in coreutils-8.32.
|
||||
+ Only `stat --cached=never` will continue to automount files.
|
||||
+
|
||||
chmod -v no longer misreports modes of dangling symlinks.
|
||||
[bug introduced in coreutils-5.3.0]
|
||||
|
||||
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
|
||||
index e9be0993a..05dc5ee21 100644
|
||||
--- a/doc/coreutils.texi
|
||||
+++ b/doc/coreutils.texi
|
||||
@@ -12608,6 +12608,7 @@ Always read the already cached attributes if available.
|
||||
|
||||
@item never
|
||||
Always sychronize with the latest file system attributes.
|
||||
+This also mounts automounted files.
|
||||
|
||||
@item default
|
||||
Leave the caching behavior to the underlying file system.
|
||||
diff --git a/src/stat.c b/src/stat.c
|
||||
index 0c34501..803340a 100644
|
||||
--- a/src/stat.c
|
||||
+++ b/src/stat.c
|
||||
@@ -1381,6 +1381,9 @@ do_stat (char const *filename, char const *format, char const *format2)
|
||||
else if (force_sync)
|
||||
flags |= AT_STATX_FORCE_SYNC;
|
||||
|
||||
+ if (! force_sync)
|
||||
+ flags |= AT_NO_AUTOMOUNT;
|
||||
+
|
||||
fd = statx (fd, pathname, flags, format_to_mask (format), &stx);
|
||||
if (fd < 0)
|
||||
{
|
||||
--
|
||||
2.33.0
|
||||
|
||||
35
backport-tac-avoid-out-of-bounds-access.patch
Normal file
35
backport-tac-avoid-out-of-bounds-access.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From d60e550ed0ba67455a5952fe8adf27dacf47e680 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Wed, 15 Jan 2025 17:42:55 +0000
|
||||
Subject: [PATCH] tac: avoid out of bounds access
|
||||
|
||||
This was flagged on CheriBSD on ARM Morello with the error:
|
||||
"In-address space security exception (core dumped)"
|
||||
triggered with: tac -s '' /dev/null
|
||||
|
||||
* src/tac.c (main): Ensure we don't read beyond the
|
||||
end of the supplied optarg.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/d60e550ed0ba67455a5952fe8adf27dacf47e680
|
||||
Conflict:NA
|
||||
|
||||
---
|
||||
src/tac.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/tac.c b/src/tac.c
|
||||
index e4aac77fe..f086f5345 100644
|
||||
--- a/src/tac.c
|
||||
+++ b/src/tac.c
|
||||
@@ -553,7 +553,7 @@ main (int argc, char **argv)
|
||||
G_buffer = xmalloc (G_buffer_size);
|
||||
if (sentinel_length)
|
||||
{
|
||||
- memcpy (G_buffer, separator, sentinel_length + 1);
|
||||
+ memcpy (G_buffer, separator, sentinel_length + !!*separator);
|
||||
G_buffer += sentinel_length;
|
||||
}
|
||||
else
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
From ab4ffc85039f7398dde2ec4b307dfb2aa0fcf4f8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Mon, 11 Mar 2024 13:46:24 +0000
|
||||
Subject: [PATCH] timeout: fix narrow race in failing to kill processes
|
||||
|
||||
* src/timeout.c (main): Block cleanup signals earlier so that cleanup()
|
||||
is not runnable until monitored_pid is in a deterministic state.
|
||||
This ensures we always send a termination signal to the child
|
||||
once it's forked.
|
||||
* NEWS: Mention the bug fix.
|
||||
Reported at https://github.com/coreutils/coreutils/issues/82
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/ab4ffc85039f7398dde2ec4b307dfb2aa0fcf4f8
|
||||
Conflict:Delete NEWS. Change nullptr to NULL.
|
||||
|
||||
---
|
||||
src/timeout.c | 32 +++++++++++++++++++++-----------
|
||||
1 file changed, 21 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/timeout.c b/src/timeout.c
|
||||
index 641592c..8fa927c 100644
|
||||
--- a/src/timeout.c
|
||||
+++ b/src/timeout.c
|
||||
@@ -249,7 +249,7 @@ cleanup (int sig)
|
||||
{ /* were in the parent, so let it continue to exit below. */
|
||||
}
|
||||
else /* monitored_pid == 0 */
|
||||
- { /* we're the child or the child is not exec'd yet. */
|
||||
+ { /* parent hasn't forked yet, or child has not exec'd yet. */
|
||||
_exit (128 + sig);
|
||||
}
|
||||
}
|
||||
@@ -538,14 +538,29 @@ main (int argc, char **argv)
|
||||
signal (SIGTTOU, SIG_IGN); /* Don't stop if background child needs tty. */
|
||||
install_sigchld (); /* Interrupt sigsuspend() when child exits. */
|
||||
|
||||
+ /* We configure timers so that SIGALRM is sent on expiry.
|
||||
+ Therefore ensure we don't inherit a mask blocking SIGALRM. */
|
||||
+ unblock_signal (SIGALRM);
|
||||
+
|
||||
+ /* Block signals now, so monitored_pid is deterministic in cleanup(). */
|
||||
+ sigset_t orig_set;
|
||||
+ block_cleanup_and_chld (term_signal, &orig_set);
|
||||
+
|
||||
monitored_pid = fork ();
|
||||
if (monitored_pid == -1)
|
||||
{
|
||||
error (0, errno, _("fork system call failed"));
|
||||
return EXIT_CANCELED;
|
||||
}
|
||||
- else if (monitored_pid == 0)
|
||||
- { /* child */
|
||||
+ else if (monitored_pid == 0) /* child */
|
||||
+ {
|
||||
+ /* Restore signal mask for child. */
|
||||
+ if (sigprocmask (SIG_SETMASK, &orig_set, NULL) != 0)
|
||||
+ {
|
||||
+ error (0, errno, _("child failed to reset signal mask"));
|
||||
+ return EXIT_CANCELED;
|
||||
+ }
|
||||
+
|
||||
/* exec doesn't reset SIG_IGN -> SIG_DFL. */
|
||||
signal (SIGTTIN, SIG_DFL);
|
||||
signal (SIGTTOU, SIG_DFL);
|
||||
@@ -562,19 +577,14 @@ main (int argc, char **argv)
|
||||
pid_t wait_result;
|
||||
int status;
|
||||
|
||||
- /* We configure timers so that SIGALRM is sent on expiry.
|
||||
- Therefore ensure we don't inherit a mask blocking SIGALRM. */
|
||||
- unblock_signal (SIGALRM);
|
||||
-
|
||||
settimeout (timeout, true);
|
||||
|
||||
- /* Ensure we don't cleanup() after waitpid() reaps the child,
|
||||
+ /* Note signals remain blocked in parent here, to ensure
|
||||
+ we don't cleanup() after waitpid() reaps the child,
|
||||
to avoid sending signals to a possibly different process. */
|
||||
- sigset_t cleanup_set;
|
||||
- block_cleanup_and_chld (term_signal, &cleanup_set);
|
||||
|
||||
while ((wait_result = waitpid (monitored_pid, &status, WNOHANG)) == 0)
|
||||
- sigsuspend (&cleanup_set); /* Wait with cleanup signals unblocked. */
|
||||
+ sigsuspend (&orig_set); /* Wait with cleanup signals unblocked. */
|
||||
|
||||
if (wait_result < 0)
|
||||
{
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
From c1cf5148a1c6302d27661ff0af772de1e7dbb2b6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Mon, 11 Mar 2024 13:18:37 +0000
|
||||
Subject: [PATCH] timeout: fix race where we might kill arbitrary processes
|
||||
|
||||
* src/timeout.c (cleanup): Handle the case where monitored_pid
|
||||
might be -1, which could happen if a signal was received
|
||||
immediately after a failed fork() call. In that case it would
|
||||
send the termination signal to all processes that the timeout
|
||||
process has permission to send signals too.
|
||||
* NEWS: Mention the bug fix.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/c1cf5148a1c6302d27661ff0af772de1e7dbb2b6
|
||||
Conflict:Delete NEWS.
|
||||
|
||||
---
|
||||
src/timeout.c | 11 ++++++++---
|
||||
1 file changed, 8 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/timeout.c b/src/timeout.c
|
||||
index 6505634..641592c 100644
|
||||
--- a/src/timeout.c
|
||||
+++ b/src/timeout.c
|
||||
@@ -208,7 +208,7 @@ cleanup (int sig)
|
||||
timed_out = 1;
|
||||
sig = term_signal;
|
||||
}
|
||||
- if (monitored_pid)
|
||||
+ if (0 < monitored_pid)
|
||||
{
|
||||
if (kill_after)
|
||||
{
|
||||
@@ -245,8 +245,13 @@ cleanup (int sig)
|
||||
}
|
||||
}
|
||||
}
|
||||
- else /* we're the child or the child is not exec'd yet. */
|
||||
- _exit (128 + sig);
|
||||
+ else if (monitored_pid == -1)
|
||||
+ { /* were in the parent, so let it continue to exit below. */
|
||||
+ }
|
||||
+ else /* monitored_pid == 0 */
|
||||
+ { /* we're the child or the child is not exec'd yet. */
|
||||
+ _exit (128 + sig);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
--
|
||||
2.33.0
|
||||
|
||||
79
backport-touch-fix-aliasing-bug.patch
Normal file
79
backport-touch-fix-aliasing-bug.patch
Normal file
@ -0,0 +1,79 @@
|
||||
From afffa445b968d2fa4397bcf1e93f3dde28689526 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Wed, 27 Jul 2022 09:59:38 -0700
|
||||
Subject: [PATCH] touch: fix aliasing bug
|
||||
|
||||
Problem reported by Tim Lange in:
|
||||
https://lists.gnu.org/r/coreutils/2022-07/msg00008.html
|
||||
* src/touch.c (date_relative): Rename from get_reldate,
|
||||
and use a functional style to fix the aliasing bug.
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/afffa445b968d2fa4397bcf1e93f3dde28689526
|
||||
Conflict:NA
|
||||
|
||||
---
|
||||
src/touch.c | 24 +++++++++++-------------
|
||||
1 file changed, 11 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/touch.c b/src/touch.c
|
||||
index 21c247d0b..d8d232c19 100644
|
||||
--- a/src/touch.c
|
||||
+++ b/src/touch.c
|
||||
@@ -105,15 +105,15 @@ static int const time_masks[] =
|
||||
CH_ATIME, CH_ATIME, CH_ATIME, CH_MTIME, CH_MTIME
|
||||
};
|
||||
|
||||
-/* Store into *RESULT the result of interpreting FLEX_DATE as a date,
|
||||
- relative to NOW. If NOW is null, use the current time. */
|
||||
+/* The interpretation of FLEX_DATE as a date, relative to NOW. */
|
||||
|
||||
-static void
|
||||
-get_reldate (struct timespec *result,
|
||||
- char const *flex_date, struct timespec const *now)
|
||||
+static struct timespec
|
||||
+date_relative (char const *flex_date, struct timespec now)
|
||||
{
|
||||
- if (! parse_datetime (result, flex_date, now))
|
||||
+ struct timespec result;
|
||||
+ if (! parse_datetime (&result, flex_date, &now))
|
||||
die (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date));
|
||||
+ return result;
|
||||
}
|
||||
|
||||
/* Update the time of file FILE according to the options given.
|
||||
@@ -356,19 +356,17 @@ main (int argc, char **argv)
|
||||
if (flex_date)
|
||||
{
|
||||
if (change_times & CH_ATIME)
|
||||
- get_reldate (&newtime[0], flex_date, &newtime[0]);
|
||||
+ newtime[0] = date_relative (flex_date, newtime[0]);
|
||||
if (change_times & CH_MTIME)
|
||||
- get_reldate (&newtime[1], flex_date, &newtime[1]);
|
||||
+ newtime[1] = date_relative (flex_date, newtime[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flex_date)
|
||||
{
|
||||
- struct timespec now;
|
||||
- gettime (&now);
|
||||
- get_reldate (&newtime[0], flex_date, &now);
|
||||
- newtime[1] = newtime[0];
|
||||
+ struct timespec now = current_timespec ();
|
||||
+ newtime[1] = newtime[0] = date_relative (flex_date, now);
|
||||
date_set = true;
|
||||
|
||||
/* If neither -a nor -m is specified, treat "-d now" as if
|
||||
@@ -383,7 +381,7 @@ main (int argc, char **argv)
|
||||
struct timespec notnow, notnow1;
|
||||
notnow.tv_sec = now.tv_sec ^ 1;
|
||||
notnow.tv_nsec = now.tv_nsec;
|
||||
- get_reldate (¬now1, flex_date, ¬now);
|
||||
+ notnow1 = date_relative (flex_date, notnow);
|
||||
if (notnow1.tv_sec == notnow.tv_sec
|
||||
&& notnow1.tv_nsec == notnow.tv_nsec)
|
||||
date_set = false;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
36
backport-yes-avoid-failure-on-CHERI-protected-systems.patch
Normal file
36
backport-yes-avoid-failure-on-CHERI-protected-systems.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From 261f13bcf84a6f7a3241bab48c074879db789fca Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
||||
Date: Wed, 15 Jan 2025 22:08:07 +0000
|
||||
Subject: [PATCH] yes: avoid failure on CHERI protected systems
|
||||
|
||||
* src/yes.c (main): Don't reuse the argv array as CHERI's
|
||||
capability bounds do not allow for that, failing like:
|
||||
$ yes $(seq 156) | head -n1
|
||||
In-address space security exception (core dumped)
|
||||
|
||||
Reference:https://github.com/coreutils/coreutils/commit/261f13bcf84a6f7a3241bab48c074879db789fca
|
||||
Conflict:NA
|
||||
|
||||
---
|
||||
src/yes.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/src/yes.c b/src/yes.c
|
||||
index 396618cb5..ceb7ce447 100644
|
||||
--- a/src/yes.c
|
||||
+++ b/src/yes.c
|
||||
@@ -96,6 +96,11 @@ main (int argc, char **argv)
|
||||
reuse_operand_strings = false;
|
||||
}
|
||||
|
||||
+#if defined __CHERI__
|
||||
+ /* Cheri capability bounds do not allow for this. */
|
||||
+ reuse_operand_strings = false;
|
||||
+#endif
|
||||
+
|
||||
/* Fill the buffer with one copy of the output. If possible, reuse
|
||||
the operands strings; this wins when the buffer would be large. */
|
||||
char *buf = reuse_operand_strings ? *operands : xmalloc (bufalloc);
|
||||
--
|
||||
2.43.0
|
||||
|
||||
108
coreutils-9.0-sw.patch
Executable file → Normal file
108
coreutils-9.0-sw.patch
Executable file → Normal file
@ -1,10 +1,12 @@
|
||||
diff -Nuar coreutils-9.0.org/build-aux/config.guess coreutils-9.0.sw/build-aux/config.guess
|
||||
--- coreutils-9.0.org/build-aux/config.guess 2022-02-17 15:38:25.880000000 +0000
|
||||
+++ coreutils-9.0.sw/build-aux/config.guess 2022-02-17 16:03:14.150000000 +0000
|
||||
@@ -973,6 +973,14 @@
|
||||
diff --git a/build-aux/config.guess b/build-aux/config.guess
|
||||
index e81d3ae..fc4976f 100755
|
||||
--- a/build-aux/config.guess
|
||||
+++ b/build-aux/config.guess
|
||||
@@ -973,6 +973,16 @@ EOF
|
||||
UNAME_MACHINE=aarch64_be
|
||||
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
|
||||
;;
|
||||
+#if defined (__sw_64)
|
||||
+ sw_64:Linux:*:*)
|
||||
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
|
||||
+ sw) UNAME_MACHINE=sw_64 ;;
|
||||
@ -13,24 +15,29 @@ diff -Nuar coreutils-9.0.org/build-aux/config.guess coreutils-9.0.sw/build-aux/c
|
||||
+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
|
||||
+ GUESS=$UNAME_MACHINE-sunway-linux-$LIBC
|
||||
+ ;;
|
||||
+#endif
|
||||
alpha:Linux:*:*)
|
||||
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
|
||||
EV5) UNAME_MACHINE=alphaev5 ;;
|
||||
diff -Nuar coreutils-9.0.org/build-aux/config.sub coreutils-9.0.sw/build-aux/config.sub
|
||||
--- coreutils-9.0.org/build-aux/config.sub 2022-02-17 15:38:25.880000000 +0000
|
||||
+++ coreutils-9.0.sw/build-aux/config.sub 2022-02-17 16:03:30.560000000 +0000
|
||||
@@ -1177,6 +1177,7 @@
|
||||
diff --git a/build-aux/config.sub b/build-aux/config.sub
|
||||
index d74fb6d..b5b01c1 100755
|
||||
--- a/build-aux/config.sub
|
||||
+++ b/build-aux/config.sub
|
||||
@@ -1177,6 +1177,9 @@ case $cpu-$vendor in
|
||||
| a29k \
|
||||
| aarch64 | aarch64_be \
|
||||
| abacus \
|
||||
+#if defined (__sw_64)
|
||||
+ | sw_64 \
|
||||
+#endif
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
|
||||
| alphapca5[67] | alpha64pca5[67] \
|
||||
diff -Nuar coreutils-9.0.org/configure coreutils-9.0.sw/configure
|
||||
--- coreutils-9.0.org/configure 2022-02-17 15:38:26.280000000 +0000
|
||||
+++ coreutils-9.0.sw/configure 2022-02-17 15:58:05.480000000 +0000
|
||||
@@ -7845,6 +7845,12 @@
|
||||
diff --git a/configure b/configure
|
||||
index ee54aad..dd92158 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -7845,6 +7845,12 @@ printf "%s\n" "#define _LARGEFILE_SOURCE 1" >>confdefs.h
|
||||
# (according to the test results of Bruno Haible's ieeefp/fenv_default.m4
|
||||
# and the GCC 4.1.2 manual).
|
||||
case "$host_cpu" in
|
||||
@ -43,42 +50,46 @@ diff -Nuar coreutils-9.0.org/configure coreutils-9.0.sw/configure
|
||||
alpha*)
|
||||
# On Alpha systems, a compiler option provides the behaviour.
|
||||
# See the ieee(3) manual page, also available at
|
||||
@@ -18808,7 +18814,7 @@
|
||||
@@ -18808,7 +18814,7 @@ else $as_nop
|
||||
case "$gl_cv_host_cpu_c_abi" in
|
||||
i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
|
||||
gl_cv_host_cpu_c_abi_32bit=yes ;;
|
||||
- x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
|
||||
+ x86_64 | sw_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
|
||||
+ x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | sw_64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
|
||||
gl_cv_host_cpu_c_abi_32bit=no ;;
|
||||
*)
|
||||
gl_cv_host_cpu_c_abi_32bit=unknown ;;
|
||||
@@ -18837,7 +18843,7 @@
|
||||
;;
|
||||
@@ -18838,7 +18844,7 @@ else $as_nop
|
||||
|
||||
# CPUs that only support a 64-bit ABI.
|
||||
- alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
|
||||
+ sw_64* | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
|
||||
| mmix )
|
||||
alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
|
||||
- | mmix )
|
||||
+ | sw_64* | mmix )
|
||||
gl_cv_host_cpu_c_abi_32bit=no
|
||||
;;
|
||||
diff -Nuar coreutils-9.0.org/lib/uname.c coreutils-9.0.sw/lib/uname.c
|
||||
--- coreutils-9.0.org/lib/uname.c 2022-02-17 15:38:26.740000000 +0000
|
||||
+++ coreutils-9.0.sw/lib/uname.c 2022-02-17 15:59:09.500000000 +0000
|
||||
@@ -228,6 +228,10 @@
|
||||
|
||||
diff --git a/lib/uname.c b/lib/uname.c
|
||||
index adb9d98..0d6284b 100644
|
||||
--- a/lib/uname.c
|
||||
+++ b/lib/uname.c
|
||||
@@ -228,6 +228,12 @@ uname (struct utsname *buf)
|
||||
case PROCESSOR_ARCHITECTURE_MIPS:
|
||||
strcpy (buf->machine, "mips");
|
||||
break;
|
||||
+#if defined (__sw_64)
|
||||
+ case PROCESSOR_ARCHITECTURE_SW_64:
|
||||
+ case PROCESSOR_ARCHITECTURE_SW_6464:
|
||||
+ strcpy (buf->machine, "sw_64");
|
||||
+ break;
|
||||
+#endif
|
||||
case PROCESSOR_ARCHITECTURE_ALPHA:
|
||||
case PROCESSOR_ARCHITECTURE_ALPHA64:
|
||||
strcpy (buf->machine, "alpha");
|
||||
diff -Nuar coreutils-9.0.org/m4/fpieee.m4 coreutils-9.0.sw/m4/fpieee.m4
|
||||
--- coreutils-9.0.org/m4/fpieee.m4 2022-02-17 15:38:25.890000000 +0000
|
||||
+++ coreutils-9.0.sw/m4/fpieee.m4 2022-02-17 15:41:57.490000000 +0000
|
||||
@@ -30,6 +30,12 @@
|
||||
diff --git a/m4/fpieee.m4 b/m4/fpieee.m4
|
||||
index 3f16957..7a6010b 100644
|
||||
--- a/m4/fpieee.m4
|
||||
+++ b/m4/fpieee.m4
|
||||
@@ -30,6 +30,12 @@ AC_DEFUN([gl_FP_IEEE],
|
||||
# (according to the test results of Bruno Haible's ieeefp/fenv_default.m4
|
||||
# and the GCC 4.1.2 manual).
|
||||
case "$host_cpu" in
|
||||
@ -91,23 +102,24 @@ diff -Nuar coreutils-9.0.org/m4/fpieee.m4 coreutils-9.0.sw/m4/fpieee.m4
|
||||
alpha*)
|
||||
# On Alpha systems, a compiler option provides the behaviour.
|
||||
# See the ieee(3) manual page, also available at
|
||||
diff -Nuar coreutils-9.0.org/m4/host-cpu-c-abi.m4 coreutils-9.0.sw/m4/host-cpu-c-abi.m4
|
||||
--- coreutils-9.0.org/m4/host-cpu-c-abi.m4 2022-02-17 15:38:25.900000000 +0000
|
||||
+++ coreutils-9.0.sw/m4/host-cpu-c-abi.m4 2022-02-17 15:41:29.970000000 +0000
|
||||
@@ -91,6 +91,12 @@
|
||||
diff --git a/m4/host-cpu-c-abi.m4 b/m4/host-cpu-c-abi.m4
|
||||
index 64e28b1..e2833aa 100644
|
||||
--- a/m4/host-cpu-c-abi.m4
|
||||
+++ b/m4/host-cpu-c-abi.m4
|
||||
@@ -90,6 +90,12 @@ changequote([,])dnl
|
||||
[gl_cv_host_cpu_c_abi=i386])
|
||||
;;
|
||||
|
||||
changequote(,)dnl
|
||||
+changequote(,)dnl
|
||||
+ sw_64* )
|
||||
+changequote([,])dnl
|
||||
+ gl_cv_host_cpu_c_abi=sw_64
|
||||
+ ;;
|
||||
+
|
||||
+changequote(,)dnl
|
||||
changequote(,)dnl
|
||||
alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
|
||||
changequote([,])dnl
|
||||
gl_cv_host_cpu_c_abi=alpha
|
||||
@@ -355,6 +361,9 @@
|
||||
@@ -355,6 +361,9 @@ EOF
|
||||
#ifndef __x86_64__
|
||||
#undef __x86_64__
|
||||
#endif
|
||||
@ -117,28 +129,29 @@ diff -Nuar coreutils-9.0.org/m4/host-cpu-c-abi.m4 coreutils-9.0.sw/m4/host-cpu-c
|
||||
#ifndef __alpha__
|
||||
#undef __alpha__
|
||||
#endif
|
||||
@@ -468,7 +477,7 @@
|
||||
@@ -468,7 +477,7 @@ AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
|
||||
case "$gl_cv_host_cpu_c_abi" in
|
||||
i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
|
||||
gl_cv_host_cpu_c_abi_32bit=yes ;;
|
||||
- x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
|
||||
+ x86_64 | sw_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
|
||||
+ x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | sw_64 | riscv*-lp64* | s390x | sparc64 )
|
||||
gl_cv_host_cpu_c_abi_32bit=no ;;
|
||||
*)
|
||||
gl_cv_host_cpu_c_abi_32bit=unknown ;;
|
||||
@@ -498,7 +507,7 @@
|
||||
|
||||
@@ -499,7 +508,7 @@ AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
|
||||
# CPUs that only support a 64-bit ABI.
|
||||
changequote(,)dnl
|
||||
- alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
|
||||
+ sw_64* | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
|
||||
| mmix )
|
||||
alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
|
||||
- | mmix )
|
||||
+ | sw_64* | mmix )
|
||||
changequote([,])dnl
|
||||
gl_cv_host_cpu_c_abi_32bit=no
|
||||
diff -Nuar coreutils-9.0.org/src/longlong.h coreutils-9.0.sw/src/longlong.h
|
||||
--- coreutils-9.0.org/src/longlong.h 2022-02-17 15:38:26.750000000 +0000
|
||||
+++ coreutils-9.0.sw/src/longlong.h 2022-02-17 15:55:26.520000000 +0000
|
||||
@@ -170,6 +170,92 @@
|
||||
;;
|
||||
diff --git a/src/longlong.h b/src/longlong.h
|
||||
index fbd3716..c99a554 100644
|
||||
--- a/src/longlong.h
|
||||
+++ b/src/longlong.h
|
||||
@@ -170,6 +170,92 @@ along with this file. If not, see https://www.gnu.org/licenses/. */
|
||||
don't need to be under !NO_ASM */
|
||||
#if ! defined (NO_ASM)
|
||||
|
||||
@ -231,3 +244,6 @@ diff -Nuar coreutils-9.0.org/src/longlong.h coreutils-9.0.sw/src/longlong.h
|
||||
#if defined (__alpha) && W_TYPE_SIZE == 64
|
||||
/* Most alpha-based machines, except Cray systems. */
|
||||
#if defined (__GNUC__)
|
||||
--
|
||||
2.43.0
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: coreutils
|
||||
Version: 9.0
|
||||
Release: 13
|
||||
Release: 18
|
||||
License: GPLv3+
|
||||
Summary: A set of basic GNU tools commonly used in shell scripts
|
||||
Url: https://www.gnu.org/software/coreutils/
|
||||
@ -41,10 +41,29 @@ Patch26: backport-doc-od-strings-clarify-operation.patch
|
||||
Patch27: backport-wc-port-to-kernels-that-disable-XSAVE-YMM.patch
|
||||
Patch28: test-skip-overlay-filesystem-because-of-no-inotify_add_watch.patch
|
||||
Patch29: fix-typo-in-zh_CN.patch
|
||||
Patch30: backport-sort-don-t-trust-st_size-on-proc-files.patch
|
||||
Patch31: backport-pinky-fix-string-size-calculation.patch
|
||||
Patch32: backport-cksum-consistently-validate-length-attributes.patch
|
||||
Patch33: backport-timeout-fix-race-where-we-might-kill-arbitrary-proce.patch
|
||||
Patch34: backport-timeout-fix-narrow-race-in-failing-to-kill-processes.patch
|
||||
Patch35: backport-maint-basenc-consistently-check-buffer-bounds-when-e.patch
|
||||
Patch36: backport-coreutils-df-direct.patch
|
||||
Patch37: backport-df-fix-memory-leak.patch
|
||||
Patch38: backport-ls-avoid-triggering-automounts.patch
|
||||
Patch39: backport-pr-don-t-use-uninitialized-var.patch
|
||||
Patch40: backport-stat-only-automount-with-cached-never.patch
|
||||
Patch41: backport-touch-fix-aliasing-bug.patch
|
||||
Patch42: backport-putenv-Don-t-crash-upon-out-of-memory.patch
|
||||
Patch43: backport-head-off_t-not-uintmax_t-for-file-offset.patch
|
||||
Patch44: backport-shuf-avoid-integer-overflow-on-huge-inputs.patch
|
||||
Patch45: backport-shuf-fix-randomness-bug.patch
|
||||
patch46: backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch
|
||||
Patch47: backport-numfmt-don-t-require-a-suffix-with-from-iec-i.patch
|
||||
patch48: backport-sort-fix-debug-buffer-overrun.patch
|
||||
patch49: backport-tac-avoid-out-of-bounds-access.patch
|
||||
Patch50: backport-yes-avoid-failure-on-CHERI-protected-systems.patch
|
||||
|
||||
%ifarch sw_64
|
||||
Patch13: coreutils-9.0-sw.patch
|
||||
%endif
|
||||
Patch9001: coreutils-9.0-sw.patch
|
||||
|
||||
Conflicts: filesystem < 3
|
||||
# To avoid clobbering installs
|
||||
@ -171,6 +190,41 @@ fi
|
||||
%{_mandir}/man*/*
|
||||
|
||||
%changelog
|
||||
* Mon Mar 3 2025 huyubiao <huyubiao@huawei.com> - 9.0-18
|
||||
- sync patches from community
|
||||
- add backport-numfmt-don-t-require-a-suffix-with-from-iec-i.patch
|
||||
backport-sort-fix-debug-buffer-overrun.patch
|
||||
backport-tac-avoid-out-of-bounds-access.patch
|
||||
backport-yes-avoid-failure-on-CHERI-protected-systems.patch
|
||||
|
||||
* Thu Nov 28 2024 huyubiao <huyubiao@huawei.com> - 9.0-17
|
||||
- sync patches from community
|
||||
- add backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch
|
||||
|
||||
* Wed Sep 11 2024 huyubiao <huyubiao@huawei.com> - 9.0-16
|
||||
- sync patches from community
|
||||
- add backport-pinky-fix-string-size-calculation.patch
|
||||
backport-cksum-consistently-validate-length-attributes.patch
|
||||
backport-timeout-fix-race-where-we-might-kill-arbitrary-proce.patch
|
||||
backport-timeout-fix-narrow-race-in-failing-to-kill-processes.patch
|
||||
backport-maint-basenc-consistently-check-buffer-bounds-when-e.patch
|
||||
backport-coreutils-df-direct.patch
|
||||
backport-df-fix-memory-leak.patch
|
||||
backport-ls-avoid-triggering-automounts.patch
|
||||
backport-pr-don-t-use-uninitialized-var.patch
|
||||
backport-stat-only-automount-with-cached-never.patch
|
||||
backport-touch-fix-aliasing-bug.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
|
||||
|
||||
* Tue Jun 25 2024 zhangxianting <zhangxianting@uniontech.com> - 9.0-15
|
||||
- remove arch judgement at patch that support sw
|
||||
|
||||
* Wed Jun 12 2024 yanglongkang <yanglongkang@h-partners.com> - 9.0-14
|
||||
- sort: don't trust st_size on /proc files
|
||||
|
||||
* Thu Nov 28 2023 jiangchuangang <jiangchuangang@huawei.com> - 9.0-13
|
||||
- fix typo in zh_CN.po
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user