Compare commits
No commits in common. "f4360ec91ef24aff67bba81b5e9e8adf6280812c" and "323dba829b775e59a617811b63c0608b7804cf02" have entirely different histories.
f4360ec91e
...
323dba829b
@ -1,81 +0,0 @@
|
||||
From 7386c291be8e2de115f2e161886e872429edadd7 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Fri, 14 Feb 2025 13:10:02 -0800
|
||||
Subject: =?UTF-8?q?cat:=20fix=20plain=20=E2=80=98cat=E2=80=99=20bug?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
* src/cat.c (main): Do not fail with plain ‘cat’ where input and
|
||||
output are both /dev/tty, if the output happens to have O_APPEND set.
|
||||
Problem reported by lilydjwg <https://bugs.gnu.org/76255>.
|
||||
Also, don’t report an error if the seek position is at or after EOF,
|
||||
even if O_APPEND is set.
|
||||
---
|
||||
src/cat.c | 26 +++++++++++++-------------
|
||||
1 file changed, 13 insertions(+), 13 deletions(-)
|
||||
|
||||
(limited to 'src/cat.c')
|
||||
|
||||
diff --git a/src/cat.c b/src/cat.c
|
||||
index 274f844..c022103 100644
|
||||
--- a/src/cat.c
|
||||
+++ b/src/cat.c
|
||||
@@ -646,9 +646,15 @@
|
||||
idx_t outsize = io_blksize (stat_buf);
|
||||
|
||||
/* Device, I-node number and lazily-acquired flags of the output. */
|
||||
- dev_t out_dev = stat_buf.st_dev;
|
||||
- ino_t out_ino = stat_buf.st_ino;
|
||||
+ dev_t out_dev;
|
||||
+ ino_t out_ino;
|
||||
int out_flags = -2;
|
||||
+ bool have_out_dev = ! (S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf));
|
||||
+ if (have_out_dev)
|
||||
+ {
|
||||
+ out_dev = stat_buf.st_dev;
|
||||
+ out_ino = stat_buf.st_ino;
|
||||
+ }
|
||||
|
||||
/* True if the output is a regular file. */
|
||||
bool out_isreg = S_ISREG (stat_buf.st_mode) != 0;
|
||||
@@ -706,22 +712,25 @@
|
||||
output device. It's better to catch this error earlier
|
||||
rather than later. */
|
||||
|
||||
- if (stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino)
|
||||
+ if (! (S_ISFIFO (stat_buf.st_mode) || S_ISSOCK (stat_buf.st_mode)
|
||||
+ || S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf))
|
||||
+ && have_out_dev
|
||||
+ && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino)
|
||||
{
|
||||
- if (out_flags < -1)
|
||||
- out_flags = fcntl (STDOUT_FILENO, F_GETFL);
|
||||
- bool exhausting = 0 <= out_flags && out_flags & O_APPEND;
|
||||
- if (!exhausting)
|
||||
- {
|
||||
- off_t in_pos = lseek (input_desc, 0, SEEK_CUR);
|
||||
- if (0 <= in_pos)
|
||||
- exhausting = in_pos < lseek (STDOUT_FILENO, 0, SEEK_CUR);
|
||||
- }
|
||||
- if (exhausting)
|
||||
+ off_t in_pos = lseek (input_desc, 0, SEEK_CUR);
|
||||
+ if (0 <= in_pos)
|
||||
{
|
||||
- error (0, 0, _("%s: input file is output file"), quotef (infile));
|
||||
- ok = false;
|
||||
- goto contin;
|
||||
+ if (out_flags < -1)
|
||||
+ out_flags = fcntl (STDOUT_FILENO, F_GETFL);
|
||||
+ int whence = (0 <= out_flags && out_flags & O_APPEND
|
||||
+ ? SEEK_END : SEEK_CUR);
|
||||
+ if (in_pos < lseek (STDOUT_FILENO, 0, whence))
|
||||
+ {
|
||||
+ error (0, 0, _("%s: input file is output file"),
|
||||
+ quotef (infile));
|
||||
+ ok = false;
|
||||
+ goto contin;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,252 +0,0 @@
|
||||
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.
|
||||
---
|
||||
src/head.c | 129 ++++++++++++++++++++++++-----------------------------
|
||||
1 file changed, 58 insertions(+), 71 deletions(-)
|
||||
|
||||
diff --git a/src/head.c b/src/head.c
|
||||
index a9155c24c..9715b7b73 100644
|
||||
--- a/src/head.c
|
||||
+++ b/src/head.c
|
||||
@@ -237,17 +237,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;
|
||||
|
||||
@@ -265,16 +264,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)];
|
||||
- error (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
|
||||
@@ -286,11 +278,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. */
|
||||
|
||||
+ static_assert (READ_BUFSIZE <= IDX_MAX);
|
||||
+ static_assert (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);
|
||||
@@ -310,7 +305,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)
|
||||
{
|
||||
@@ -320,7 +315,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;
|
||||
@@ -330,15 +325,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,31 +345,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 = nullptr;
|
||||
- /* 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)
|
||||
{
|
||||
@@ -403,43 +391,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
|
||||
|
||||
@ -1,64 +0,0 @@
|
||||
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
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
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
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
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
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
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
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: coreutils
|
||||
Version: 9.4
|
||||
Release: 15
|
||||
Release: 10
|
||||
License: GPLv3+
|
||||
Summary: A set of basic GNU tools commonly used in shell scripts
|
||||
Url: https://www.gnu.org/software/coreutils/
|
||||
@ -37,12 +37,6 @@ Patch22: backport-putenv-Don-t-crash-upon-out-of-memory.patch
|
||||
Patch23: backport-head-off_t-not-uintmax_t-for-file-offset.patch
|
||||
Patch24: backport-shuf-avoid-integer-overflow-on-huge-inputs.patch
|
||||
Patch25: backport-shuf-fix-randomness-bug.patch
|
||||
Patch26: backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch
|
||||
Patch27: backport-numfmt-don-t-require-a-suffix-with-from-iec-i.patch
|
||||
patch28: backport-sort-fix-debug-buffer-overrun.patch
|
||||
patch29: backport-tac-avoid-out-of-bounds-access.patch
|
||||
Patch30: backport-yes-avoid-failure-on-CHERI-protected-systems.patch
|
||||
Patch31: backport-cat-fix-plain-cat-bug.patch
|
||||
|
||||
Patch9001: coreutils-9.0-sw.patch
|
||||
|
||||
@ -94,10 +88,6 @@ find tests -name '*.sh' -perm 0644 -print -exec chmod 0755 '{}' '+'
|
||||
(echo "<<< done") 2>/dev/null
|
||||
|
||||
autoreconf -fiv
|
||||
%ifarch sw_64
|
||||
/usr/bin/cp -fv /usr/lib/rpm/%{_vendor}/config.guess build-aux/
|
||||
/usr/bin/cp -fv /usr/lib/rpm/%{_vendor}/config.sub build-aux/
|
||||
%endif
|
||||
|
||||
%build
|
||||
if [ %user = root ]; then
|
||||
@ -187,27 +177,6 @@ fi
|
||||
%{_mandir}/man*/*
|
||||
|
||||
%changelog
|
||||
* Mon Mar 24 2025 mahailiang <mahailiang@uniontech.com> - 9.4-15
|
||||
- modify cp to /usr/bin/cp
|
||||
|
||||
* Mon Mar 17 2025 yixiangzhike <yixiangzhike007@163.com> - 9.4-14
|
||||
- backport upstream patches
|
||||
fix cat bug appearing in conjunction with gawk
|
||||
|
||||
* Wed Mar 12 2025 mahailiang <mahailiang@uniontech.com> - 9.4-13
|
||||
- fix sw_64 build error
|
||||
|
||||
* Wed Mar 05 2025 hugel <gengqihu2@h-partners.com> - 9.4-12
|
||||
- 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.4-11
|
||||
- sync patches from community
|
||||
- add backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch
|
||||
|
||||
* Wed Sep 11 2024 huyubiao <huyubiao@huawei.com> - 9.4-10
|
||||
- sync patches from community
|
||||
- add backport-pinky-fix-string-size-calculation.patch
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user