Resolves: #2112870 - prevent unexpand from failing on control characters

This commit is contained in:
Kamil Dudka 2022-08-01 17:17:07 +02:00
parent 2158b83433
commit e0f6afe5e6
2 changed files with 13 additions and 8 deletions

View File

@ -19,7 +19,7 @@ Subject: [PATCH] coreutils-i18n.patch
src/local.mk | 4 +- src/local.mk | 4 +-
src/pr.c | 443 ++++++++++++++++++-- src/pr.c | 443 ++++++++++++++++++--
src/sort.c | 792 +++++++++++++++++++++++++++++++++--- src/sort.c | 792 +++++++++++++++++++++++++++++++++---
src/unexpand.c | 101 ++++- src/unexpand.c | 103 ++++-
src/uniq.c | 119 +++++- src/uniq.c | 119 +++++-
tests/Coreutils.pm | 3 + tests/Coreutils.pm | 3 +
tests/expand/mb.sh | 183 +++++++++ tests/expand/mb.sh | 183 +++++++++
@ -35,7 +35,7 @@ Subject: [PATCH] coreutils-i18n.patch
tests/misc/uniq.pl | 55 +++ tests/misc/uniq.pl | 55 +++
tests/pr/pr-tests.pl | 49 +++ tests/pr/pr-tests.pl | 49 +++
tests/unexpand/mb.sh | 172 ++++++++ tests/unexpand/mb.sh | 172 ++++++++
31 files changed, 3698 insertions(+), 242 deletions(-) 31 files changed, 3700 insertions(+), 242 deletions(-)
create mode 100644 lib/mbfile.c create mode 100644 lib/mbfile.c
create mode 100644 lib/mbfile.h create mode 100644 lib/mbfile.h
create mode 100644 m4/mbfile.m4 create mode 100644 m4/mbfile.m4
@ -4273,7 +4273,7 @@ index 7d6100f..04cd646 100644
{ {
/* Go back one column, and force recalculation of the /* Go back one column, and force recalculation of the
next tab stop. */ next tab stop. */
@@ -218,9 +277,9 @@ unexpand (void) @@ -218,9 +277,11 @@ unexpand (void)
next_tab_column = column; next_tab_column = column;
tab_index -= !!tab_index; tab_index -= !!tab_index;
} }
@ -4281,11 +4281,13 @@ index 7d6100f..04cd646 100644
+ else if (!mb_iseq (c, '\n')) + else if (!mb_iseq (c, '\n'))
{ {
- column++; - column++;
+ column += mb_width (c); + /* mb_width() returns 0 for control characters */
+ const int width = mb_width (c);
+ column += (width) ? width : 1;
if (!column) if (!column)
die (EXIT_FAILURE, 0, _("input line is too long")); die (EXIT_FAILURE, 0, _("input line is too long"));
} }
@@ -228,8 +287,11 @@ unexpand (void) @@ -228,8 +289,11 @@ unexpand (void)
if (pending) if (pending)
{ {
if (pending > 1 && one_blank_before_tab_stop) if (pending > 1 && one_blank_before_tab_stop)
@ -4299,7 +4301,7 @@ index 7d6100f..04cd646 100644
die (EXIT_FAILURE, errno, _("write error")); die (EXIT_FAILURE, errno, _("write error"));
pending = 0; pending = 0;
one_blank_before_tab_stop = false; one_blank_before_tab_stop = false;
@@ -239,16 +301,17 @@ unexpand (void) @@ -239,16 +303,17 @@ unexpand (void)
convert &= convert_entire_line || blank; convert &= convert_entire_line || blank;
} }
@ -4489,7 +4491,7 @@ diff --git a/tests/Coreutils.pm b/tests/Coreutils.pm
index fad7ab9..c9021a6 100644 index fad7ab9..c9021a6 100644
--- a/tests/Coreutils.pm --- a/tests/Coreutils.pm
+++ b/tests/Coreutils.pm +++ b/tests/Coreutils.pm
@@ -264,6 +264,9 @@ sub run_tests ($$$$$) @@ -269,6 +269,9 @@ sub run_tests ($$$$$)
# Yes, this is an arbitrary limit. If it causes trouble, # Yes, this is an arbitrary limit. If it causes trouble,
# consider removing it. # consider removing it.
my $max = 30; my $max = 30;

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils Name: coreutils
Version: 9.1 Version: 9.1
Release: 3%{?dist} Release: 4%{?dist}
License: GPLv3+ License: GPLv3+
Url: https://www.gnu.org/software/coreutils/ Url: https://www.gnu.org/software/coreutils/
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
@ -265,6 +265,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING %license COPYING
%changelog %changelog
* Mon Aug 01 2022 Kamil Dudka <kdudka@redhat.com> - 9.1-4
- prevent unexpand from failing on control characters (#2112870)
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> * Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild