summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/coreutils/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/coreutils/coreutils')
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch26
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch99
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch112
-rw-r--r--meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch64
-rw-r--r--meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch49
-rw-r--r--meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch36
-rw-r--r--meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch7
7 files changed, 115 insertions, 278 deletions
diff --git a/meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch b/meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch
deleted file mode 100644
index 66f9a716c9..0000000000
--- a/meta/recipes-core/coreutils/coreutils/0001-local.mk-fix-cross-compiling-problem.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1Subject: local.mk: fix cross compiling problem
2
3We meet the following error when cross compiling.
4| Makefile:3418: *** Recursive variable 'INSTALL' references itself (eventually). Stop.
5This patch fixes this problem.
6
7Upstream-Status: Pending
8
9Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
10---
11 src/local.mk | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/src/local.mk b/src/local.mk
15index 36dfa4e..c5898cc 100644
16--- a/src/local.mk
17+++ b/src/local.mk
18@@ -649,4 +649,4 @@ cu_install_program = @INSTALL_PROGRAM@
19 else
20 cu_install_program = src/ginstall
21 endif
22-INSTALL = $(cu_install_program) -c
23+INSTALL_PROGRAM = $(cu_install_program)
24--
252.1.0
26
diff --git a/meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch b/meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch
deleted file mode 100644
index fa900e3a76..0000000000
--- a/meta/recipes-core/coreutils/coreutils/0001-ls-restore-8.31-behavior-on-removed-directories.patch
+++ /dev/null
@@ -1,99 +0,0 @@
1From 7c273e5c6041f8c70f73f5b280fbb8f27d9b5a36 Mon Sep 17 00:00:00 2001
2From: Paul Eggert <eggert@cs.ucla.edu>
3Date: Thu, 5 Mar 2020 17:25:29 -0800
4Subject: [PATCH] ls: restore 8.31 behavior on removed directories
5
6* NEWS: Mention this.
7* src/ls.c: Do not include <sys/sycall.h>
8(print_dir): Don't worry about whether the directory is removed.
9* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
10behavior.
11
12Upstream-Status: Backport [https://github.com/coreutils/coreutils/commit/10fcb97bd728f09d4a027eddf8ad2900f0819b0a]
13Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
14---
15 src/ls.c | 22 ----------------------
16 tests/ls/removed-directory.sh | 10 ++--------
17 2 files changed, 2 insertions(+), 30 deletions(-)
18
19diff --git a/src/ls.c b/src/ls.c
20index 637fe7a..0111f49 100644
21--- a/src/ls.c
22+++ b/src/ls.c
23@@ -49,10 +49,6 @@
24 # include <sys/ptem.h>
25 #endif
26
27-#ifdef __linux__
28-# include <sys/syscall.h>
29-#endif
30-
31 #include <stdio.h>
32 #include <assert.h>
33 #include <setjmp.h>
34@@ -2895,7 +2891,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
35 struct dirent *next;
36 uintmax_t total_blocks = 0;
37 static bool first = true;
38- bool found_any_entries = false;
39
40 errno = 0;
41 dirp = opendir (name);
42@@ -2971,7 +2966,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
43 next = readdir (dirp);
44 if (next)
45 {
46- found_any_entries = true;
47 if (! file_ignored (next->d_name))
48 {
49 enum filetype type = unknown;
50@@ -3017,22 +3011,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
51 if (errno != EOVERFLOW)
52 break;
53 }
54-#ifdef __linux__
55- else if (! found_any_entries)
56- {
57- /* If readdir finds no directory entries at all, not even "." or
58- "..", then double check that the directory exists. */
59- if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
60- && errno != EINVAL)
61- {
62- /* We exclude EINVAL as that pertains to buffer handling,
63- and we've passed NULL as the buffer for simplicity.
64- ENOENT is returned if appropriate before buffer handling. */
65- file_failure (command_line_arg, _("reading directory %s"), name);
66- }
67- break;
68- }
69-#endif
70 else
71 break;
72
73diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
74index e8c835d..fe8f929 100755
75--- a/tests/ls/removed-directory.sh
76+++ b/tests/ls/removed-directory.sh
77@@ -26,20 +26,14 @@ case $host_triplet in
78 *) skip_ 'non linux kernel' ;;
79 esac
80
81-LS_FAILURE=2
82-
83-cat <<\EOF >exp-err || framework_failure_
84-ls: reading directory '.': No such file or directory
85-EOF
86-
87 cwd=$(pwd)
88 mkdir d || framework_failure_
89 cd d || framework_failure_
90 rmdir ../d || framework_failure_
91
92-returns_ $LS_FAILURE ls >../out 2>../err || fail=1
93+ls >../out 2>../err || fail=1
94 cd "$cwd" || framework_failure_
95 compare /dev/null out || fail=1
96-compare exp-err err || fail=1
97+compare /dev/null err || fail=1
98
99 Exit $fail
diff --git a/meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch b/meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch
new file mode 100644
index 0000000000..41be1635b5
--- /dev/null
+++ b/meta/recipes-core/coreutils/coreutils/0001-sort-fix-buffer-under-read-CWE-127.patch
@@ -0,0 +1,112 @@
1From 8763c305c29d0abb7e2be4695212b42917d054b2 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
3Date: Tue, 20 May 2025 16:03:44 +0100
4Subject: [PATCH] sort: fix buffer under-read (CWE-127)
5
6* src/sort.c (begfield): Check pointer adjustment
7to avoid Out-of-range pointer offset (CWE-823).
8(limfield): Likewise.
9* tests/sort/sort-field-limit.sh: Add a new test,
10which triggers with ASAN or Valgrind.
11* tests/local.mk: Reference the new test.
12* NEWS: Mention bug fix introduced in v7.2 (2009).
13Fixes https://bugs.gnu.org/78507
14
15CVE: CVE-2025-5278
16
17Upstream-Status: Backport [https://cgit.git.savannah.gnu.org/cgit/coreutils.git/commit/?id=8c9602e3a145e9596dc1a63c6ed67865814b6633]
18
19Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
20---
21 src/sort.c | 12 ++++++++++--
22 tests/local.mk | 1 +
23 tests/sort/sort-field-limit.sh | 35 ++++++++++++++++++++++++++++++++++
24 3 files changed, 46 insertions(+), 2 deletions(-)
25 create mode 100755 tests/sort/sort-field-limit.sh
26
27diff --git a/src/sort.c b/src/sort.c
28index b10183b6f..7af1a2512 100644
29--- a/src/sort.c
30+++ b/src/sort.c
31@@ -1644,7 +1644,11 @@ begfield (struct line const *line, struct keyfield const *key)
32 ++ptr;
33
34 /* Advance PTR by SCHAR (if possible), but no further than LIM. */
35- ptr = MIN (lim, ptr + schar);
36+ size_t remaining_bytes = lim - ptr;
37+ if (schar < remaining_bytes)
38+ ptr += schar;
39+ else
40+ ptr = lim;
41
42 return ptr;
43 }
44@@ -1746,7 +1750,11 @@ limfield (struct line const *line, struct keyfield const *key)
45 ++ptr;
46
47 /* Advance PTR by ECHAR (if possible), but no further than LIM. */
48- ptr = MIN (lim, ptr + echar);
49+ size_t remaining_bytes = lim - ptr;
50+ if (echar < remaining_bytes)
51+ ptr += echar;
52+ else
53+ ptr = lim;
54 }
55
56 return ptr;
57diff --git a/tests/local.mk b/tests/local.mk
58index 4da6756ac..642d225fa 100644
59--- a/tests/local.mk
60+++ b/tests/local.mk
61@@ -388,6 +388,7 @@ all_tests = \
62 tests/sort/sort-debug-keys.sh \
63 tests/sort/sort-debug-warn.sh \
64 tests/sort/sort-discrim.sh \
65+ tests/sort/sort-field-limit.sh \
66 tests/sort/sort-files0-from.pl \
67 tests/sort/sort-float.sh \
68 tests/sort/sort-h-thousands-sep.sh \
69diff --git a/tests/sort/sort-field-limit.sh b/tests/sort/sort-field-limit.sh
70new file mode 100755
71index 000000000..52d8e1d17
72--- /dev/null
73+++ b/tests/sort/sort-field-limit.sh
74@@ -0,0 +1,35 @@
75+#!/bin/sh
76+# From 7.2-9.7, this would trigger an out of bounds mem read
77+
78+# Copyright (C) 2025 Free Software Foundation, Inc.
79+
80+# This program is free software: you can redistribute it and/or modify
81+# it under the terms of the GNU General Public License as published by
82+# the Free Software Foundation, either version 3 of the License, or
83+# (at your option) any later version.
84+
85+# This program is distributed in the hope that it will be useful,
86+# but WITHOUT ANY WARRANTY; without even the implied warranty of
87+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88+# GNU General Public License for more details.
89+
90+# You should have received a copy of the GNU General Public License
91+# along with this program. If not, see <https://www.gnu.org/licenses/>.
92+
93+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
94+print_ver_ sort
95+getlimits_
96+
97+# This issue triggers with valgrind or ASAN
98+valgrind --error-exitcode=1 sort --version 2>/dev/null &&
99+ VALGRIND='valgrind --error-exitcode=1'
100+
101+{ printf '%s\n' aa bb; } > in || framework_failure_
102+
103+_POSIX2_VERSION=200809 $VALGRIND sort +0.${SIZE_MAX}R in > out || fail=1
104+compare in out || fail=1
105+
106+_POSIX2_VERSION=200809 $VALGRIND sort +1 -1.${SIZE_MAX}R in > out || fail=1
107+compare in out || fail=1
108+
109+Exit $fail
110--
1112.34.1
112
diff --git a/meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch b/meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch
deleted file mode 100644
index 3c43e1d5da..0000000000
--- a/meta/recipes-core/coreutils/coreutils/0001-uname-report-processor-and-hardware-correctly.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1Upstream-Status: Denied
2
3Subject: uname: report processor and hardware correctly
4
5This patch is rejected by coreutils upstream, but distros like debian and fedora
6uses this patch to make `uname -i' and `uname -p' to not report 'unknown'.
7
8Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
9---
10 src/uname.c | 18 ++++++++++++++++--
11 1 file changed, 16 insertions(+), 2 deletions(-)
12
13diff --git a/src/uname.c b/src/uname.c
14index 39bd28c..c84582d 100644
15--- a/src/uname.c
16+++ b/src/uname.c
17@@ -299,13 +299,19 @@ main (int argc, char **argv)
18
19 if (toprint & PRINT_PROCESSOR)
20 {
21- char const *element = unknown;
22+ char *element = unknown;
23 #if HAVE_SYSINFO && defined SI_ARCHITECTURE
24 {
25 static char processor[257];
26 if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
27 element = processor;
28 }
29+#else
30+ {
31+ static struct utsname u;
32+ uname(&u);
33+ element = u.machine;
34+ }
35 #endif
36 #ifdef UNAME_PROCESSOR
37 if (element == unknown)
38@@ -343,7 +349,7 @@ main (int argc, char **argv)
39
40 if (toprint & PRINT_HARDWARE_PLATFORM)
41 {
42- char const *element = unknown;
43+ char *element = unknown;
44 #if HAVE_SYSINFO && defined SI_PLATFORM
45 {
46 static char hardware_platform[257];
47@@ -361,6 +367,14 @@ main (int argc, char **argv)
48 if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0)
49 element = hardware_platform;
50 }
51+#else
52+ {
53+ static struct utsname u;
54+ uname(&u);
55+ element = u.machine;
56+ if(strlen(element)==4 && element[0]=='i' && element[2]=='8' && element[3]=='6')
57+ element[1]='3';
58+ }
59 #endif
60 if (! (toprint == UINT_MAX && element == unknown))
61 print_element (element);
62--
631.9.1
64
diff --git a/meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch b/meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch
deleted file mode 100644
index e68c213550..0000000000
--- a/meta/recipes-core/coreutils/coreutils/disable-ls-output-quoting.patch
+++ /dev/null
@@ -1,49 +0,0 @@
1Subject: revert inconsistent ls quoting
2
3This is a revert of upstream commit 109b9220cead6e979d22d16327c4d9f8350431cc.
4
5Bug-Debian: https://bugs.debian.org/813164
6
7Upstream-Status: Submitted
8
9Originally-by: Adam Borowski <kilobyte@angband.pl>
10[PG: patch from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813164#78 ]
11Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
12
13---
14
15--- coreutils-8.25.orig/NEWS
16+++ coreutils-8.25/NEWS
17@@ -71,9 +71,6 @@ GNU coreutils NEWS
18 df now prefers sources towards the root of a device when
19 eliding duplicate bind mounted entries.
20
21- ls now quotes file names unambiguously and appropriate for use in a shell,
22- when outputting to a terminal.
23-
24 join, sort, uniq with --zero-terminated, now treat '\n' as a field delimiter.
25
26 ** Improvements
27--- coreutils-8.25.orig/doc/coreutils.texi
28+++ coreutils-8.25/doc/coreutils.texi
29@@ -7750,8 +7750,8 @@ this"} in the default C locale. This lo
30
31 You can specify the default value of the @option{--quoting-style} option
32 with the environment variable @env{QUOTING_STYLE}@. If that environment
33-variable is not set, the default value is @samp{shell-escape} when the
34-output is a terminal, and @samp{literal} otherwise.
35+variable is not set, the default value is @samp{literal}, but this
36+default may change to @samp{shell} in a future version of this package.
37
38 @item --show-control-chars
39 @opindex --show-control-chars
40--- coreutils-8.25.orig/src/ls.c
41+++ coreutils-8.25/src/ls.c
42@@ -1581,7 +1581,6 @@ decode_switches (int argc, char **argv)
43 if (isatty (STDOUT_FILENO))
44 {
45 format = many_per_line;
46- set_quoting_style (NULL, shell_escape_quoting_style);
47 /* See description of qmark_funny_chars, above. */
48 qmark_funny_chars = true;
49 }
diff --git a/meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch b/meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch
deleted file mode 100644
index 173a57925b..0000000000
--- a/meta/recipes-core/coreutils/coreutils/fix-selinux-flask.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From 7e20a7242ba2657f73311bbf5278093da67f0721 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 16 Sep 2014 01:59:08 -0700
4Subject: [PATCH] gnulib-comp.m4: selinux/flask.h should respect to
5 with_selinux
6
7Fixed when build with meta-selinux even when --without-selinux:
8runcon.c:49:28: fatal error: selinux/flask.h: No such file or directory
9 # include <selinux/flask.h>
10 ^
11compilation terminated.
12
13Upstream-Status: Pending
14
15Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
16
17---
18 m4/gnulib-comp.m4 | 2 +-
19 1 file changed, 1 insertion(+), 1 deletion(-)
20
21diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
22index dead90e..0abf0bd 100644
23--- a/m4/gnulib-comp.m4
24+++ b/m4/gnulib-comp.m4
25@@ -1860,10 +1860,10 @@ AC_DEFUN([gl_INIT],
26 AC_LIBOBJ([select])
27 fi
28 gl_SYS_SELECT_MODULE_INDICATOR([select])
29- AC_CHECK_HEADERS([selinux/flask.h])
30 gl_HEADERS_SELINUX_SELINUX_H
31 gl_HEADERS_SELINUX_CONTEXT_H
32 if test "$with_selinux" != no && test "$ac_cv_header_selinux_selinux_h" = yes; then
33+ AC_CHECK_HEADERS([selinux/flask.h])
34 AC_LIBOBJ([getfilecon])
35 fi
36 gl_SERVENT
diff --git a/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch b/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch
index 1a8a9b9983..718de0ab78 100644
--- a/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch
+++ b/meta/recipes-core/coreutils/coreutils/remove-usr-local-lib-from-m4.patch
@@ -1,4 +1,4 @@
1From a26530083a29eeee910bfd606ecc621acecd547a Mon Sep 17 00:00:00 2001 1From f53ffb5b27ab7d4a4c62df00ebd6a1a6936d1709 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 3 Aug 2011 14:12:30 -0700 3Date: Wed, 3 Aug 2011 14:12:30 -0700
4Subject: [PATCH] coreutils: Fix build on uclibc 4Subject: [PATCH] coreutils: Fix build on uclibc
@@ -12,16 +12,15 @@ and make life easier for cross compilation process.
12Signed-off-by: Khem Raj <raj.khem@gmail.com> 12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13 13
14Upstream-Status: Inappropriate [Upstream does care for AIX while we may not] 14Upstream-Status: Inappropriate [Upstream does care for AIX while we may not]
15
16--- 15---
17 m4/getloadavg.m4 | 12 ------------ 16 m4/getloadavg.m4 | 12 ------------
18 1 file changed, 12 deletions(-) 17 1 file changed, 12 deletions(-)
19 18
20diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4 19diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4
21index 8e96965..63782a2 100644 20index 9d0236f..68f7c52 100644
22--- a/m4/getloadavg.m4 21--- a/m4/getloadavg.m4
23+++ b/m4/getloadavg.m4 22+++ b/m4/getloadavg.m4
24@@ -41,18 +41,6 @@ AC_CHECK_FUNC([getloadavg], [], 23@@ -46,18 +46,6 @@ if test $ac_cv_func_getloadavg != yes; then
25 [LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes]) 24 [LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes])
26 fi 25 fi
27 26