Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
fd71f3d315
!159 [sync] PR-155: sort: don't trust st_size on /proc files
From: @openeuler-sync-bot 
Reviewed-by: @openeuler-basic 
Signed-off-by: @openeuler-basic
2024-06-17 01:10:07 +00:00
markeryang
85ebfa5a3d sort: don't trust st_size on /proc files
(cherry picked from commit 20b17aa3d046e61609b06f83c82087e0b60c47b8)
2024-06-14 11:16:22 +08:00
openeuler-ci-bot
f5e6754869
!151 [sync] PR-124: coreutils: fix typo in zh_CN.po
From: @openeuler-sync-bot 
Reviewed-by: @openeuler-basic 
Signed-off-by: @openeuler-basic
2024-06-07 01:59:00 +00:00
jcg
5dcb672798 coreutils: fix typo in zh_CN.po
(cherry picked from commit ea339237dd9f440527a6109f924e74de0c220f2a)
2024-06-06 17:00:57 +08:00
openeuler-ci-bot
9c2855debc
!117 [sync] PR-115: coreutils: skip testcase inotify-rotate-resources.sh for overlay filesystem in docker
From: @openeuler-sync-bot 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2023-11-27 08:37:00 +00:00
jcg
cdeeed80cc coreutils: skip testcase for overlay filesystem because of no inotify_add_watch
(cherry picked from commit abefd63d0584c87bdcf899521f99c6688779d1af)
2023-11-25 17:04:26 +08:00
openeuler-ci-bot
aad5a8a5a0
!108 [sync] PR-107: coreutils:sync patches from community
From: @openeuler-sync-bot 
Reviewed-by: @ship_harbour 
Signed-off-by: @ship_harbour
2023-10-10 08:31:01 +00:00
fly_fzc
b1840f7ab9 coreutils:sync patches from community
(cherry picked from commit c77ff335ff89d7cb9ad7caaa6f19d3437996991d)
2023-10-10 15:09:34 +08:00
openeuler-ci-bot
dab411492f
!98 [sync] PR-97: sync patches from community
From: @openeuler-sync-bot 
Reviewed-by: @openeuler-basic 
Signed-off-by: @openeuler-basic
2023-06-15 08:45:46 +00:00
jcg
dad668acde coreutils:sync patches from community
add backport-pr-fix-infinite-loop-when-double-spacing.patch
backport-wc-ensure-we-update-file-offset.patch

(cherry picked from commit 35b82816a56ba097b007b72461342f93bba4ed2a)
2023-06-15 15:28:34 +08:00
12 changed files with 798 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From 66ea09b0fecb4fa1e4de78e3738bdbb1442b3f31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Thu, 8 Jun 2023 10:58:10 +0100
Subject: [PATCH] doc: od --strings: clarify operation
* doc/coreutils.texi (od invocation): Remove mention of ASCII,
as all printable characters in unibyte locales are output.
* src/od.c (usage): Clarify that only NUL terminated strings
are displayed, and that it's printable chars, not only graphic chars
that are output. I.e., spaces are output also if part of the string.
Reported at https://bugs.ddebian.org/1037217
Reference:https://github.com/coreutils/coreutils/commit/66ea09b0fecb4fa1e4de78e3738bdbb1442b3f31
Conflict:NA
---
doc/coreutils.texi | 2 +-
src/od.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 6a693e283..e9d7b8eb4 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -2058,7 +2058,7 @@ Output at most @var{bytes} bytes of the input. Prefixes and suffixes on
@opindex --strings
@cindex string constants, outputting
Instead of the normal output, output only @dfn{string constants}: at
-least @var{bytes} consecutive ASCII graphic characters,
+least @var{bytes} consecutive printable characters,
followed by a zero byte (ASCII NUL).
Prefixes and suffixes on @var{bytes} are interpreted as for the
@option{-j} option.
diff --git a/src/od.c b/src/od.c
index 10a28e21f..f68407008 100644
--- a/src/od.c
+++ b/src/od.c
@@ -356,9 +356,8 @@ suffixes may be . for octal and b for multiply by 512.\n\
"), stdout);
fputs (_("\
-N, --read-bytes=BYTES limit dump to BYTES input bytes\n\
- -S BYTES, --strings[=BYTES] output strings of at least BYTES graphic chars;\
-\n\
- 3 is implied when BYTES is not specified\n\
+ -S BYTES, --strings[=BYTES] show only NUL terminated strings\n\
+ of at least BYTES (3) printable characters\n\
-t, --format=TYPE select output format or formats\n\
-v, --output-duplicates do not use * to mark line suppression\n\
-w[BYTES], --width[=BYTES] output BYTES bytes per output line;\n\
--
2.27.0

View File

@ -0,0 +1,66 @@
From 3fb0cc80fa5e1cede9ec05303a70c26d0d23ca1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Tue, 25 Apr 2023 14:07:03 +0100
Subject: [PATCH] pr: fix infinite loop when double spacing
* src/pr.c (init_parameters): Ensure we avoid a 0 lines_per_body
which was possible when adjusting for double spacing.
That caused print_page() to always return true,
causing an infinite loop.
* tests/pr/pr-tests.pl: Add a test case.
* NEWS: Mention the fix.
Fixes https://bugs.debian.org/1034808
Conflict:NEWS context adaption
Reference:https://github.com/coreutils/coreutils/commit/3fb0cc80fa5e1cede9ec05303a70c26d0d23ca1d
---
NEWS | 3 +++
src/pr.c | 2 +-
tests/pr/pr-tests.pl | 3 +++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index f65eb95..5320b9c 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 9.0 (2021-09-24) [stable]
** Bug fixes
+ 'pr --length=1 --double-space' no longer enters an infinite loop.
+ [This bug was present in "the beginning".]
+
tail --follow=name works again with non seekable files. Previously it
exited with an "Illegal seek" error when such a file was replaced.
[bug introduced in fileutils-4.1.6]
diff --git a/src/pr.c b/src/pr.c
index 2c5cdceb1..14a368b6c 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -1209,7 +1209,7 @@ init_parameters (int number_of_files)
lines_per_body = lines_per_page;
if (double_space)
- lines_per_body = lines_per_body / 2;
+ lines_per_body = MAX (1, lines_per_body / 2);
/* If input is stdin, cannot print parallel files. BSD dumps core
on this. */
diff --git a/tests/pr/pr-tests.pl b/tests/pr/pr-tests.pl
index 265e6e108..eafc13d81 100755
--- a/tests/pr/pr-tests.pl
+++ b/tests/pr/pr-tests.pl
@@ -415,6 +415,9 @@ my @tv = (
['padding2', '-t -n,64', "1\n", (" "x 63)."1,1\n", 0],
# Ensure we handle buffer truncation correctly
['padding3', '-t -N1000000 -n,1', "1\n", "0,1\n", 0],
+
+# This entered an infinite loop before coreutils-9.4
+['page-length1', '-dl1', "", "", 0],
);
# Convert the above old-style test vectors to the newer
--
2.36.1

View File

@ -0,0 +1,47 @@
From 6c9b59a9c20c1422346f74ae3cd558f3317deb6a Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Fri, 2 Jun 2023 20:11:36 +0200
Subject: [PATCH] setenv: Don't crash if malloc() returns NULL.
* lib/setenv.c (rpl_setenv): Check malloca() return value.
Reference:https://github.com/coreutils/gnulib/commit/6c9b59a9c20c1422346f74ae3cd558f3317deb6a
Conflict:Changelog Context adaptation
---
ChangeLog | 5 +++++
lib/setenv.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 869096eb41..48fe27441e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-06-02 Bruno Haible <bruno@clisp.org>
+
+ setenv: Don't crash if malloc() returns NULL.
+ * lib/setenv.c (rpl_setenv): Check malloca() return value.
+
2023-02-27 ChuanGang Jiang <jiangchuanganghw@outlook.com>
fts: fail gracefully when out of memory
diff --git a/lib/setenv.c b/lib/setenv.c
index f0b889969f..22b12fd018 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -375,6 +375,11 @@ rpl_setenv (const char *name, const char *value, int replace)
int saved_errno;
size_t len = strlen (value);
tmp = malloca (len + 2);
+ if (tmp == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
/* Since leading '=' is eaten, double it up. */
*tmp = '=';
memcpy (tmp + 1, value, len + 1);
--
2.27.0

View 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): Dont 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

View File

@ -0,0 +1,70 @@
From 779f34e180fdcabddb24acc2829410ce8ed50fd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Mon, 31 Jul 2023 12:41:26 +0100
Subject: [PATCH] tac: handle short reads on input
This can be reproduced by getting the read() above 2G,
which induces a short read, thus triggering the erroneous failure.
$ truncate -s 5G 5G
$ cat 5G | TMPDIR=$PWD tac | wc -c
tac: /tmp/tacFt7txA: read error: Illegal seek
0
With the fix in place we now get:
$ cat 5G | TMPDIR=$PWD src/tac | wc -c
5368709120
* src/tac.c (tac_seekable): Use full_read() to handle short reads.
* NEWS: Mention the bug fix.
Reported at https://bugs.debian.org/1042546
Reference:https://github.com/coreutils/coreutils/commit/779f34e180fdcabddb24acc2829410ce8ed50fd1
Conflict:NEWS Context adaptation
---
NEWS | 4 ++++
src/tac.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 41205fa88..2b8f984ba 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,10 @@ GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 9.0 (2021-09-24) [stable]
** Bug fixes
+ tac now handles short reads on its input. Previously it may have exited
+ erroneously, especially with large input files with no separators.
+ [This bug was present in "the beginning".]
+
`wc -c` will again correctly update the read offset of inputs.
Previously it deduced the size of inputs while leaving the offset unchanged.
[bug introduced in coreutils-8.27]
diff --git a/src/tac.c b/src/tac.c
index 285f99a74..4c3655895 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -46,6 +46,7 @@ tac -r -s '.\|
#include "die.h"
#include "error.h"
#include "filenamecat.h"
+#include "full-read.h"
#include "safe-read.h"
#include "stdlib--.h"
#include "xbinary-io.h"
@@ -352,7 +353,7 @@ tac_seekable (int input_fd, char const *file, off_t file_pos)
else
match_start = past_end;
- if (safe_read (input_fd, G_buffer, read_size) != read_size)
+ if (full_read (input_fd, G_buffer, read_size) != read_size)
{
error (0, errno, _("%s: read error"), quotef (file));
return false;
--
2.27.0

View File

@ -0,0 +1,75 @@
From ce630dfc7ef32ff7e35c627bd061a45ce9053d9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Sun, 5 Feb 2023 19:52:31 +0000
Subject: [PATCH] wc: ensure we update file offset
* src/wc.c (wc): Update the offset when not reading,
and do read if we can't update the offset.
* tests/misc/wc-proc.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/61300
Conflict:NEWS and tests/misc/wc-proc.sh context adaption
Reference:https://github.com/coreutils/coreutils/commit/ce630dfc7ef32ff7e35c627bd061a45ce9053d9d
---
NEWS | 4 ++++
src/wc.c | 5 ++++-
tests/misc/wc-proc.sh | 12 ++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 5320b9c..ce6e2b7 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,10 @@ GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 9.0 (2021-09-24) [stable]
** Bug fixes
+ `wc -c` will again correctly update the read offset of inputs.
+ Previously it deduced the size of inputs while leaving the offset unchanged.
+ [bug introduced in coreutils-8.27]
+
'pr --length=1 --double-space' no longer enters an infinite loop.
[This bug was present in "the beginning".]
diff --git a/src/wc.c b/src/wc.c
index 801396a15..becceda98 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -450,7 +450,10 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos)
beyond the end of the file. As in the example above. */
bytes = end_pos < current_pos ? 0 : end_pos - current_pos;
- skip_read = true;
+ if (bytes && 0 <= lseek (fd, bytes, SEEK_CUR))
+ skip_read = true;
+ else
+ bytes = 0;
}
else
{
diff --git a/tests/misc/wc-proc.sh b/tests/misc/wc-proc.sh
index 5eb43b982..2307f2c38 100755
--- a/tests/misc/wc-proc.sh
+++ b/tests/misc/wc-proc.sh
@@ -42,4 +42,16 @@ cat <<\EOF > exp
EOF
compare exp out || fail=1
+# Ensure we update the offset even when not reading,
+# which wasn't the case from coreutils-8.27 to coreutils-9.2
+{ wc -c; wc -c; } < no_read > out || fail=1
+{ wc -c; wc -c; } < do_read >> out || fail=1
+cat <<\EOF > exp
+2
+0
+1048576
+0
+EOF
+compare exp out || fail=1
+
Exit $fail
--
2.36.1

View File

@ -0,0 +1,263 @@
From 91a74d361461494dd546467e83bc36c24185d6e7 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 13 Jun 2023 21:10:24 -0700
Subject: [PATCH] wc: port to kernels that disable XSAVE YMM
Problem reported by Dave Hansen <https://bugs.gnu.org/64058>.
Apply similar change to cksum and pclmul, too.
* NEWS: Mention wc fix.
* configure.ac (cpuid_exists, get_cpuid_count_exists):
Remove. All uses removed, since we no longer use __get_cpuid or
__get_cpuid_count.
(pclmul_intrinsic_exists, avx2_intrinsic_exists): Set to no if
__builtin_cpu_supports calls cannot be compiled.
(HAVE_PCLMUL_INTRINSIC, HAVE_AVX2_INTRINSIC): Remove; unused.
Simplify surrounding code because of this.
* src/cksum.c (pclmul_supported):
* src/wc.c (avx2_supported):
Use __builtin_cpu_supports instead of doing it by hand.
Simplify surrounding code because of this.
Reference:https://github.com/coreutils/coreutils/commit/91a74d361461494dd546467e83bc36c24185d6e7
Conflict:remove "a = _mm_shuffle_epi8 (a, b);" in configure.ac because it doesn't exist
---
NEWS | 3 +++
configure.ac | 67 ++++++++--------------------------------------------
src/cksum.c | 26 +++++---------------
src/wc.c | 50 +++++----------------------------------
4 files changed, 25 insertions(+), 121 deletions(-)
diff --git a/NEWS b/NEWS
index 7df9ff5b0..3350f9871 100644
--- a/NEWS
+++ b/NEWS
@@ -103,6 +103,9 @@ GNU coreutils NEWS -*- outline -*-
on (1024*5) buffer boundaries
[bug introduced in coreutils-8.31]
+ 'wc -l' no longer crashes on x86 Linux kernels that disable XSAVE YMM.
+ [bug introduced in coreutils-9.0]
+
** Changes in behavior
cp and install now default to copy-on-write (COW) if available.
diff --git a/configure.ac b/configure.ac
index 520de8184..48dea9d01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -527,27 +527,6 @@ CFLAGS=$ac_save_CFLAGS
LDFLAGS=$ac_save_LDFLAGS
ac_c_werror_flag=$cu_save_c_werror_flag
-AC_MSG_CHECKING([if __get_cpuid available])
-AC_LINK_IFELSE(
- [AC_LANG_SOURCE([[
- #include <cpuid.h>
-
- int
- main (void)
- {
- unsigned int eax, ebx, ecx, edx;
- __get_cpuid (1, &eax, &ebx, &ecx, &edx);
- return 1;
- }
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_CPUID], [1], [__get_cpuid available])
- cpuid_exists=yes
- ],[
- AC_MSG_RESULT([no])
- ])
-
ac_save_CFLAGS=$CFLAGS
CFLAGS="-mavx -mpclmul $CFLAGS"
AC_MSG_CHECKING([if pclmul intrinsic exists])
@@ -560,46 +539,23 @@ AC_COMPILE_IFELSE(
{
__m128i a, b;
a = _mm_clmulepi64_si128 (a, b, 0x00);
- return 1;
+ return __builtin_cpu_supports ("pclmul");
}
]])
],[
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_PCLMUL_INTRINSIC], [1], [pclmul intrinsic exists])
pclmul_intrinsic_exists=yes
],[
- AC_MSG_RESULT([no])
+ pclmul_intrinsic_exists=no
])
-if test "x$cpuid_exists" = "xyes" &&
- test "x$pclmul_intrinsic_exists" = "xyes"; then
+AC_MSG_RESULT([$pclmul_intrinsic_exists])
+if test $pclmul_intrinsic_exists = yes; then
AC_DEFINE([USE_PCLMUL_CRC32], [1],
[CRC32 calculation by pclmul hardware instruction enabled])
fi
AM_CONDITIONAL([USE_PCLMUL_CRC32],
- [test "x$cpuid_exists" = "xyes" &&
- test "x$pclmul_intrinsic_exists" = "xyes"])
+ [test $pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
-AC_MSG_CHECKING([if __get_cpuid_count exists])
-AC_LINK_IFELSE(
- [AC_LANG_SOURCE([[
- #include <cpuid.h>
-
- int
- main (void)
- {
- unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
- __get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx);
- return 1;
- }
- ]])
- ],[
- AC_MSG_RESULT([yes])
- get_cpuid_count_exists=yes
- ],[
- AC_MSG_RESULT([no])
- ])
-
CFLAGS="-mavx2 $CFLAGS"
AC_MSG_CHECKING([if avx2 intrinstics exists])
AC_COMPILE_IFELSE(
@@ -611,23 +567,20 @@ AC_COMPILE_IFELSE(
{
__m256i a, b;
a = _mm256_sad_epu8 (a, b);
- return 1;
+ return __builtin_cpu_supports ("avx2");
}
]])
],[
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_AVX2_INTRINSIC], [1], [avx2 intrinsics exists])
avx2_intrinsic_exists=yes
],[
- AC_MSG_RESULT([no])
+ avx2_intrinsic_exists=no
])
-if test "x$get_cpuid_count_exists" = "xyes" &&
- test "x$avx2_intrinsic_exists" = "xyes"; then
+AC_MSG_RESULT([$avx2_intrinsic_exists])
+if test $avx2_intrinsic_exists = yes; then
AC_DEFINE([USE_AVX2_WC_LINECOUNT], [1], [Counting lines with AVX2 enabled])
fi
AM_CONDITIONAL([USE_AVX2_WC_LINECOUNT],
- [test "x$get_cpuid_count_exists" = "xyes" &&
- test "x$avx2_intrinsic_exists" = "xyes"])
+ [test $avx2_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
diff --git a/src/cksum.c b/src/cksum.c
index 85afab0ac..631ac3449 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -159,29 +159,15 @@ static bool
pclmul_supported (void)
{
# if USE_PCLMUL_CRC32
- unsigned int eax = 0;
- unsigned int ebx = 0;
- unsigned int ecx = 0;
- unsigned int edx = 0;
-
- if (! __get_cpuid (1, &eax, &ebx, &ecx, &edx))
- {
- if (cksum_debug)
- error (0, 0, "%s", _("failed to get cpuid"));
- return false;
- }
-
- if (! (ecx & bit_PCLMUL) || ! (ecx & bit_AVX))
- {
- if (cksum_debug)
- error (0, 0, "%s", _("pclmul support not detected"));
- return false;
- }
+ bool pclmul_enabled = 0 < __builtin_cpu_supports ("pclmul");
if (cksum_debug)
- error (0, 0, "%s", _("using pclmul hardware support"));
+ error (0, 0, "%s",
+ (pclmul_enabled
+ ? _("using pclmul hardware support")
+ : _("pclmul support not detected")));
- return true;
+ return pclmul_enabled;
# else
if (cksum_debug)
error (0, 0, "%s", _("using generic hardware support"));
diff --git a/src/wc.c b/src/wc.c
index becceda98..3708d0b8f 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -132,52 +132,14 @@ static struct option const longopts[] =
static bool
avx2_supported (void)
{
- unsigned int eax = 0;
- unsigned int ebx = 0;
- unsigned int ecx = 0;
- unsigned int edx = 0;
- bool getcpuid_ok = false;
- bool avx_enabled = false;
-
- if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- {
- getcpuid_ok = true;
- if (ecx & bit_OSXSAVE)
- avx_enabled = true; /* Support is not disabled. */
- }
-
-
- if (avx_enabled)
- {
- eax = ebx = ecx = edx = 0;
- if (! __get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
- getcpuid_ok = false;
- else
- {
- if (! (ebx & bit_AVX2))
- avx_enabled = false; /* Hardware doesn't support it. */
- }
- }
+ bool avx_enabled = 0 < __builtin_cpu_supports ("avx2");
+ if (debug)
+ error (0, 0, (avx_enabled
+ ? _("using avx2 hardware support")
+ : _("avx2 support not detected")));
- if (! getcpuid_ok)
- {
- if (debug)
- error (0, 0, "%s", _("failed to get cpuid"));
- return false;
- }
- else if (! avx_enabled)
- {
- if (debug)
- error (0, 0, "%s", _("avx2 support not detected"));
- return false;
- }
- else
- {
- if (debug)
- error (0, 0, "%s", _("using avx2 hardware support"));
- return true;
- }
+ return avx_enabled;
}
#endif
--
2.27.0

View File

@ -0,0 +1,49 @@
From 123d03dca47c4d8e0dc896dd8c5732329e6acffe Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 1 Jul 2023 11:31:41 -0700
Subject: [PATCH] =?UTF-8?q?who:=20don=E2=80=99t=20crash=20if=20clock=20gyr?=
=?UTF-8?q?ates?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/who.c (idle_string): Avoid signed integer overflow
if the superuser messes with the clock in bizarre ways.
Remove an assume that wasnt correct under this scenario.
Reference:https://github.com/coreutils/coreutils/commit/123d03dca47c4d8e0dc896dd8c5732329e6acffe
Conflict:Context adaptation
---
src/who.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/who.c b/src/who.c
index 362408a42..cff1b822b 100644
--- a/src/who.c
+++ b/src/who.c
@@ -189,17 +189,16 @@ idle_string (time_t when, time_t boottime)
if (now == TYPE_MINIMUM (time_t))
time (&now);
- if (boottime < when && now - 24 * 60 * 60 < when && when <= now)
+ int seconds_idle;
+ if (boottime < when && when <= now
+ && ! INT_SUBTRACT_WRAPV (now, when, &seconds_idle)
+ && seconds_idle < 24 * 60 * 60)
{
- int seconds_idle = now - when;
if (seconds_idle < 60)
return " . ";
else
{
static char idle_hhmm[IDLESTR_LEN];
- /* FIXME-in-2018: see if this assert is still required in order
- to suppress gcc's unwarranted -Wformat-length= warning. */
- assert (seconds_idle / (60 * 60) < 24);
sprintf (idle_hhmm, "%02d:%02d",
seconds_idle / (60 * 60),
(seconds_idle % (60 * 60)) / 60);
--
2.27.0

View File

@ -0,0 +1,37 @@
From 9cbda6e1f8fdd4d7ffae26edcabceb239ed14ece Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 31 Jul 2023 11:21:25 -0700
Subject: [PATCH] who: fix only-theoretical overflow
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Change stzncpys implementation to match its comment, in the case
where SRC + LEN would overflow. This case never happens in coreutils.
* src/system.h (stzncpy): Work even if SRC + LEN would overflow.
Reference:https://github.com/coreutils/coreutils/commit/9cbda6e1f8fdd4d7ffae26edcabceb239ed14ece
Conflict:NA
---
src/system.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/system.h b/src/system.h
index db1a6773b..2d9c47f48 100644
--- a/src/system.h
+++ b/src/system.h
@@ -781,8 +781,8 @@ write_error (void)
static inline char *
stzncpy (char *restrict dest, char const *restrict src, size_t len)
{
- char const *src_end = src + len;
- while (src < src_end && *src)
+ size_t i;
+ for (i = 0; i < len && *src; i++)
*dest++ = *src++;
*dest = 0;
return dest;
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: coreutils
Version: 9.0
Release: 9
Release: 14
License: GPLv3+
Summary: A set of basic GNU tools commonly used in shell scripts
Url: https://www.gnu.org/software/coreutils/
@ -31,6 +31,17 @@ Patch16: backport-stty-fix-off-by-one-column-wrapping-on-output.patch
Patch17: backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch
Patch18: backport-tail-fix-support-for-F-with-non-seekable-files.patch
Patch19: backport-fts-fail-gracefully-when-out-of-memory.patch
Patch20: backport-pr-fix-infinite-loop-when-double-spacing.patch
Patch21: backport-wc-ensure-we-update-file-offset.patch
Patch22: backport-who-fix-only-theoretical-overflow.patch
Patch23: backport-tac-handle-short-reads-on-input.patch
Patch24: backport-setenv-Don-t-crash-if-malloc-returns-NULL.patch
Patch25: backport-who-don-t-crash-if-clock-gyrates.patch
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
%ifarch sw_64
Patch13: coreutils-9.0-sw.patch
@ -82,6 +93,8 @@ find tests -name '*.sh' -perm 0644 -print -exec chmod 0755 '{}' '+'
autoreconf -fiv
msgfmt -o po/zh_CN.gmo po/zh_CN.po ||:
%build
if [ %user = root ]; then
export FORCE_UNSAFE_CONFIGURE=1
@ -159,6 +172,30 @@ fi
%{_mandir}/man*/*
%changelog
* 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
* Sat Nov 25 2023 jiangchuangang <jiangchuangang@huawei.com> - 9.0-12
- skip testcase for overlay filesystem because of no inotify_add_watch
add test-skip-overlay-filesystem-because-of-no-inotify_add_watch.patch
* Sun Oct 08 2023 fuanan <fuanan3@h-partners.com> - 9.0-11
- sync patches from community
- add backport-who-fix-only-theoretical-overflow.patch
backport-tac-handle-short-reads-on-input.patch
backport-setenv-Don-t-crash-if-malloc-returns-NULL.patch
backport-who-don-t-crash-if-clock-gyrates.patch
backport-doc-od-strings-clarify-operation.patch
backport-wc-port-to-kernels-that-disable-XSAVE-YMM.patch
* Thu Jun 15 2023 jiangchuangang<jiangchuangang@huawei.com> - 9.0-10
- sync patches from community
- add backport-pr-fix-infinite-loop-when-double-spacing.patch
backport-wc-ensure-we-update-file-offset.patch
* Fri Mar 17 2023 jiangchuangang<jiangchuangang@huawei.com> - 9.0-9
- add backport-fts-fail-gracefully-when-out-of-memory.patch for malloc failed

24
fix-typo-in-zh_CN.patch Normal file
View File

@ -0,0 +1,24 @@
From 5bc6bb2956c1a5dfca5a00b49f56441a76054c89 Mon Sep 17 00:00:00 2001
From: jiangchuangang <jiangchuangang@huawei.com>
Date: Thu, 9 Nov 2023 10:43:07 +0800
Subject: [PATCH] fix typo
---
po/zh_CN.po | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/po/zh_CN.po b/po/zh_CN.po
index c422028..177d014 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -12332,7 +12332,7 @@ msgstr ""
" -v, --kernel-version 输出内核版本\n"
" -m, --machine 输出主机的硬件架构名称\n"
" -p, --processor 输出处理器类型(不可移植)\n"
-" -i, --hardware-platform 输出硬件平台或(不可移植)\n"
+" -i, --hardware-platform 输出硬件平台(不可移植)\n"
" -o, --operating-system 输出操作系统名称\n"
#: src/uname.c:144
--
2.36.1

View File

@ -0,0 +1,45 @@
From 8dc094e77603c61a9b86b448c3128cf61ea66d8a Mon Sep 17 00:00:00 2001
From: jiangchuangang <jiangchuangang@huawei.com>
Date: Sat, 25 Nov 2023 09:11:43 +0800
Subject: [PATCH] test: skip overlay filesystem because of no inotify_add_watch
---
tests/tail-2/inotify-dir-recreate.sh | 5 +++++
tests/tail-2/inotify-rotate-resources.sh | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/tests/tail-2/inotify-dir-recreate.sh b/tests/tail-2/inotify-dir-recreate.sh
index 469876b..2af2aed 100755
--- a/tests/tail-2/inotify-dir-recreate.sh
+++ b/tests/tail-2/inotify-dir-recreate.sh
@@ -21,6 +21,11 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tail
+filesystem=$(df -T $(pwd) | awk 'NR==2 {print $2}')
+if [ x"$filesystem" == x"overlay" ]; then
+ skip_ 'overlay filesystem skipped, no inotify_add_watch'
+fi
+
grep '^#define HAVE_INOTIFY 1' "$CONFIG_HEADER" >/dev/null && is_local_dir_ . \
|| skip_ 'inotify is not supported'
diff --git a/tests/tail-2/inotify-rotate-resources.sh b/tests/tail-2/inotify-rotate-resources.sh
index 6fa65ff..838a9a1 100755
--- a/tests/tail-2/inotify-rotate-resources.sh
+++ b/tests/tail-2/inotify-rotate-resources.sh
@@ -22,6 +22,11 @@ print_ver_ tail
# Inotify not used on remote file systems
require_local_dir_
+filesystem=$(df -T $(pwd) | awk 'NR==2 {print $2}')
+if [ x"$filesystem" == x"overlay" ]; then
+ skip_ 'overlay filesystem skipped, no inotify_add_watch'
+fi
+
grep '^#define HAVE_INOTIFY 1' "$CONFIG_HEADER" >/dev/null \
|| skip_ 'inotify required'
--
2.36.1