diff --git a/coreutils-8.32-expr-unmatched-par.patch b/coreutils-8.32-expr-unmatched-par.patch new file mode 100644 index 0000000..1a82384 --- /dev/null +++ b/coreutils-8.32-expr-unmatched-par.patch @@ -0,0 +1,81 @@ +From 9618fb718b75920f37e5be2049ad1d0bb5c4a28c Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Tue, 26 Jan 2021 09:23:54 -0800 +Subject: [PATCH] expr: fix bug with unmatched \(...\) + +Problem reported by Qiuhao Li. +* doc/coreutils.texi (String expressions): +Document the correct behavior, which POSIX requires. +* src/expr.c (docolon): Treat unmatched \(...\) as empty. +* tests/misc/expr.pl: New test. + +Upstream-commit: 735083ba24878075235007b4417982ad5700436d +Signed-off-by: Kamil Dudka +--- + doc/coreutils.texi | 14 ++++++++------ + src/expr.c | 9 +++++++-- + tests/misc/expr.pl | 3 +++ + 3 files changed, 18 insertions(+), 8 deletions(-) + +diff --git a/doc/coreutils.texi b/doc/coreutils.texi +index 2382a16..5b2bb2c 100644 +--- a/doc/coreutils.texi ++++ b/doc/coreutils.texi +@@ -13529,12 +13529,14 @@ second is considered to be a (basic, a la GNU @code{grep}) regular + expression, with a @code{^} implicitly prepended. The first argument is + then matched against this regular expression. + +-If the match succeeds and @var{regex} uses @samp{\(} and @samp{\)}, the +-@code{:} expression returns the part of @var{string} that matched the +-subexpression; otherwise, it returns the number of characters matched. +- +-If the match fails, the @code{:} operator returns the null string if +-@samp{\(} and @samp{\)} are used in @var{regex}, otherwise 0. ++If @var{regex} does not use @samp{\(} and @samp{\)}, the @code{:} ++expression returns the number of characters matched, or 0 if the match ++fails. ++ ++If @var{regex} uses @samp{\(} and @samp{\)}, the @code{:} expression ++returns the part of @var{string} that matched the subexpression, or ++the null string if the match failed or the subexpression did not ++contribute to the match. + + @kindex \( @r{regexp operator} + Only the first @samp{\( @dots{} \)} pair is relevant to the return +diff --git a/src/expr.c b/src/expr.c +index e134872..0616a42 100644 +--- a/src/expr.c ++++ b/src/expr.c +@@ -721,8 +721,13 @@ docolon (VALUE *sv, VALUE *pv) + /* Were \(...\) used? */ + if (re_buffer.re_nsub > 0) + { +- sv->u.s[re_regs.end[1]] = '\0'; +- v = str_value (sv->u.s + re_regs.start[1]); ++ if (re_regs.end[1] < 0) ++ v = str_value (""); ++ else ++ { ++ sv->u.s[re_regs.end[1]] = '\0'; ++ v = str_value (sv->u.s + re_regs.start[1]); ++ } + } + else + { +diff --git a/tests/misc/expr.pl b/tests/misc/expr.pl +index e45f8e7..e57f79d 100755 +--- a/tests/misc/expr.pl ++++ b/tests/misc/expr.pl +@@ -84,6 +84,9 @@ my @Tests = + # In 5.94 and earlier, anchors incorrectly matched newlines. + ['anchor', "'a\nb' : 'a\$'", {OUT => '0'}, {EXIT => 1}], + ++ # In 8.32, \( ... \) that did not match caused memory errors. ++ ['emptysub', '"a" : "\\(b\\)*"', {OUT => ''}, {EXIT => 1}], ++ + # These tests are taken from grep/tests/bre.tests. + ['bre1', '"abc" : "a\\(b\\)c"', {OUT => 'b'}], + ['bre2', '"a(" : "a("', {OUT => '2'}], +-- +2.26.2 + diff --git a/coreutils-8.32-ls-scontext-crash.patch b/coreutils-8.32-ls-scontext-crash.patch new file mode 100644 index 0000000..a3ddff9 --- /dev/null +++ b/coreutils-8.32-ls-scontext-crash.patch @@ -0,0 +1,85 @@ +From 53c6b01e8e3fd338d7f53e5ff817ef86f9efa852 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Wed, 11 Nov 2020 17:22:33 +0000 +Subject: [PATCH] ls: fix crash printing SELinux context for unstatable files + +This crash was identified by Cyber Independent Testing Lab: +https://cyber-itl.org/2020/10/28/citl-7000-defects.html +and was introduced with commit v6.9.90-11-g4245876e2 + +* src/ls.c (gobble_file): Ensure scontext is initialized +in the case where files are not statable. +* tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh, +and added test case for broken symlinks. +* tests/local.mk: Adjust for the renamed test. + +Upstream-commit: 6fc695cb4a26f09dfeef8b1c24895a707055334e +Signed-off-by: Kamil Dudka +--- + src/ls.c | 3 +++ + tests/local.mk | 2 +- + .../{proc-selinux-segfault.sh => selinux-segfault.sh} | 10 ++++++++-- + 3 files changed, 12 insertions(+), 3 deletions(-) + rename tests/ls/{proc-selinux-segfault.sh => selinux-segfault.sh} (77%) + +diff --git a/src/ls.c b/src/ls.c +index 4acf5f4..8eb483d 100644 +--- a/src/ls.c ++++ b/src/ls.c +@@ -3412,6 +3412,9 @@ gobble_file (char const *name, enum filetype type, ino_t inode, + provokes an exit status of 1. */ + file_failure (command_line_arg, + _("cannot access %s"), full_name); ++ ++ f->scontext = UNKNOWN_SECURITY_CONTEXT; ++ + if (command_line_arg) + return 0; + +diff --git a/tests/local.mk b/tests/local.mk +index 2aeff2b..2441fdc 100644 +--- a/tests/local.mk ++++ b/tests/local.mk +@@ -616,7 +616,7 @@ all_tests = \ + tests/ls/multihardlink.sh \ + tests/ls/no-arg.sh \ + tests/ls/no-cap.sh \ +- tests/ls/proc-selinux-segfault.sh \ ++ tests/ls/selinux-segfault.sh \ + tests/ls/quote-align.sh \ + tests/ls/readdir-mountpoint-inode.sh \ + tests/ls/recursive.sh \ +diff --git a/tests/ls/proc-selinux-segfault.sh b/tests/ls/selinux-segfault.sh +similarity index 77% +rename from tests/ls/proc-selinux-segfault.sh +rename to tests/ls/selinux-segfault.sh +index 831a00e..e2b7ef6 100755 +--- a/tests/ls/proc-selinux-segfault.sh ++++ b/tests/ls/selinux-segfault.sh +@@ -1,5 +1,5 @@ + #!/bin/sh +-# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1 ++# Ensure we don't segfault in selinux handling + + # Copyright (C) 2008-2020 Free Software Foundation, Inc. + +@@ -19,9 +19,15 @@ + . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src + print_ver_ ls + ++# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1 + f=/proc/sys + test -r $f || f=. +- + ls -l $f > out || fail=1 + ++# ls <= 8.32 would segfault when printing ++# the security context of broken symlink targets ++mkdir sedir || framework_failure_ ++ln -sf missing sedir/broken || framework_failure_ ++returns_ 1 ls -L -R -Z -m sedir > out || fail=1 ++ + Exit $fail +-- +2.26.2 + diff --git a/coreutils-8.32-split-number.patch b/coreutils-8.32-split-number.patch new file mode 100644 index 0000000..89541bf --- /dev/null +++ b/coreutils-8.32-split-number.patch @@ -0,0 +1,100 @@ +From bb0e7fabcaed9a7e71e30f05e638e9f243cdb13e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Mon, 25 Jan 2021 14:12:48 +0000 +Subject: [PATCH] split: fix --number=K/N to output correct part of file + +This functionality regressed with the adjustments +in commit v8.25-4-g62e7af032 + +* src/split.c (bytes_chunk_extract): Account for already read data +when seeking into the file. +* tests/split/b-chunk.sh: Use the hidden ---io-blksize option, +to test this functionality. +Fixes https://bugs.gnu.org/46048 + +Upstream-commit: bb21daa125aeb4e32546309d370918ca47e612db +Signed-off-by: Kamil Dudka +--- + src/split.c | 2 +- + tests/split/b-chunk.sh | 45 ++++++++++++++++++++++++------------------ + 2 files changed, 27 insertions(+), 20 deletions(-) + +diff --git a/src/split.c b/src/split.c +index 09e610b..19248f6 100644 +--- a/src/split.c ++++ b/src/split.c +@@ -1001,7 +1001,7 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize, + } + else + { +- if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0) ++ if (lseek (STDIN_FILENO, start - initial_read, SEEK_CUR) < 0) + die (EXIT_FAILURE, errno, "%s", quotef (infile)); + initial_read = SIZE_MAX; + } +diff --git a/tests/split/b-chunk.sh b/tests/split/b-chunk.sh +index 864ce55..39a6799 100755 +--- a/tests/split/b-chunk.sh ++++ b/tests/split/b-chunk.sh +@@ -35,32 +35,39 @@ split -e -n 10 /dev/null || fail=1 + returns_ 1 stat x?? 2>/dev/null || fail=1 + + printf '1\n2\n3\n4\n5\n' > input || framework_failure_ ++printf '1\n2' > exp-1 || framework_failure_ ++printf '\n3\n' > exp-2 || framework_failure_ ++printf '4\n5\n' > exp-3 || framework_failure_ + + for file in input /proc/version /sys/kernel/profiling; do + test -f $file || continue + +- split -n 3 $file > out || fail=1 +- split -n 1/3 $file > b1 || fail=1 +- split -n 2/3 $file > b2 || fail=1 +- split -n 3/3 $file > b3 || fail=1 ++ for blksize in 1 2 4096; do ++ if ! test "$file" = 'input'; then ++ # For /proc like files we must be able to read all ++ # into the internal buffer to be able to determine size. ++ test "$blksize" = 4096 || continue ++ fi + +- case $file in +- input) +- printf '1\n2' > exp-1 +- printf '\n3\n' > exp-2 +- printf '4\n5\n' > exp-3 ++ split -n 3 ---io-blksize=$blksize $file > out || fail=1 ++ split -n 1/3 ---io-blksize=$blksize $file > b1 || fail=1 ++ split -n 2/3 ---io-blksize=$blksize $file > b2 || fail=1 ++ split -n 3/3 ---io-blksize=$blksize $file > b3 || fail=1 + +- compare exp-1 xaa || fail=1 +- compare exp-2 xab || fail=1 +- compare exp-3 xac || fail=1 +- ;; +- esac ++ case $file in ++ input) ++ compare exp-1 xaa || fail=1 ++ compare exp-2 xab || fail=1 ++ compare exp-3 xac || fail=1 ++ ;; ++ esac + +- compare xaa b1 || fail=1 +- compare xab b2 || fail=1 +- compare xac b3 || fail=1 +- cat xaa xab xac | compare - $file || fail=1 +- test -f xad && fail=1 ++ compare xaa b1 || fail=1 ++ compare xab b2 || fail=1 ++ compare xac b3 || fail=1 ++ cat xaa xab xac | compare - $file || fail=1 ++ test -f xad && fail=1 ++ done + done + + Exit $fail +-- +2.26.2 + diff --git a/coreutils.spec b/coreutils.spec index 0b7bd49..a2dbc5b 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.32 -Release: 15%{?dist} +Release: 18%{?dist} License: GPLv3+ Url: https://www.gnu.org/software/coreutils/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -31,6 +31,15 @@ Patch5: coreutils-8.32-new-fs-types.patch # rm: do not skip files upon failure to remove an empty dir (#1905481) Patch6: coreutils-8.32-rm-stray-skip.patch +# expr: fix invalid read with unmatched \(...\) (#1919775) +Patch7: coreutils-8.32-expr-unmatched-par.patch + +# split: fix --number=K/N to output correct part of file (#1921246) +Patch8: coreutils-8.32-split-number.patch + +# ls: fix crash printing SELinux context for unstatable files (#1921249) +Patch9: coreutils-8.32-ls-scontext-crash.patch + # disable the test-lock gnulib test prone to deadlock Patch100: coreutils-8.26-test-lock.patch @@ -91,6 +100,7 @@ BuildRequires: libattr-devel BuildRequires: libcap-devel BuildRequires: libselinux-devel BuildRequires: libselinux-utils +BuildRequires: make BuildRequires: openssl-devel BuildRequires: strace BuildRequires: texinfo @@ -136,6 +146,10 @@ packaged as a single multicall binary. # yum obsoleting rules explained at: # https://bugzilla.redhat.com/show_bug.cgi?id=1107973#c7 Obsoletes: %{name} < 8.24-100 + +# info doc refers to "Specifying the Time Zone" from glibc-doc (#959597) +Recommends: glibc-doc + Recommends: ncurses Summary: coreutils common optional components %description common @@ -283,6 +297,17 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Wed Feb 03 2021 Kamil Dudka - 8.32-18 +- make coreutils-common recommend glibc-doc for info doc refs (#959597) + +* Tue Feb 02 2021 Kamil Dudka - 8.32-17 +- ls: fix crash printing SELinux context for unstatable files (#1921249) +- split: fix --number=K/N to output correct part of file (#1921246) +- expr: fix invalid read with unmatched \(...\) (#1919775) + +* Tue Jan 26 2021 Fedora Release Engineering +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Tue Dec 08 2020 Kamil Dudka - 8.32-15 - rm: do not skip files upon failure to remove an empty dir (#1905481)