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

This commit is contained in:
Kamil Dudka 2022-08-01 17:17:07 +02:00
parent 8338a42f2d
commit b628109850
3 changed files with 10 additions and 35 deletions

View File

@ -588,16 +588,18 @@ index 7801274..569a7ee 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. */
@@ -221,7 +235,7 @@ unexpand (void) @@ -221,16 +235,20 @@ unexpand (void)
} }
else else
{ {
- column++; - column++;
- if (!column)
+ const uintmax_t orig_column = column;
+ column += mb_width (c); + column += mb_width (c);
if (!column) + if (column < orig_column)
die (EXIT_FAILURE, 0, _("input line is too long")); die (EXIT_FAILURE, 0, _("input line is too long"));
} }
@@ -229,8 +243,11 @@ unexpand (void)
if (pending) if (pending)
{ {
if (pending > 1 && one_blank_before_tab_stop) if (pending > 1 && one_blank_before_tab_stop)
@ -611,7 +613,7 @@ index 7801274..569a7ee 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;
@@ -240,16 +257,17 @@ unexpand (void) @@ -240,16 +258,17 @@ unexpand (void)
convert &= convert_entire_line || blank; convert &= convert_entire_line || blank;
} }

View File

@ -1,28 +0,0 @@
From 02424bfcd719bbaa695f4e1c3ef17ad91b0d23c0 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Thu, 28 Jan 2016 20:57:22 +0100
Subject: [PATCH] unexpand: fix blank line handling
echo '' |./src/unexpand -a
Really?
---
src/unexpand.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/unexpand.c b/src/unexpand.c
index 569a7ee..3bbbd66 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -233,7 +233,7 @@ unexpand (void)
next_tab_column = column;
tab_index -= !!tab_index;
}
- else
+ else if (!mb_iseq (c, '\n'))
{
column += mb_width (c);
if (!column)
--
2.7.4

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: 8.32 Version: 8.32
Release: 32%{?dist} Release: 33%{?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
@ -93,8 +93,6 @@ Patch800: coreutils-i18n.patch
Patch801: coreutils-i18n-expand-unexpand.patch Patch801: coreutils-i18n-expand-unexpand.patch
# i18n patch for cut - old version - used # i18n patch for cut - old version - used
Patch804: coreutils-i18n-cut-old.patch Patch804: coreutils-i18n-cut-old.patch
# The unexpand patch above is not correct. Sent to the patch authors
Patch803: coreutils-i18n-fix-unexpand.patch
#(un)expand - allow multiple files on input - broken by patch 801 #(un)expand - allow multiple files on input - broken by patch 801
Patch805: coreutils-i18n-fix2-expand-unexpand.patch Patch805: coreutils-i18n-fix2-expand-unexpand.patch
#(un)expand - test BOM headers #(un)expand - test BOM headers
@ -323,6 +321,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING %license COPYING
%changelog %changelog
* Mon Aug 01 2022 Kamil Dudka <kdudka@redhat.com> - 8.32-33
- prevent unexpand from failing on control characters (#2112870)
* Tue Mar 01 2022 Kamil Dudka <kdudka@redhat.com> - 8.32-32 * Tue Mar 01 2022 Kamil Dudka <kdudka@redhat.com> - 8.32-32
- ls, stat: avoid triggering automounts (#2044981) - ls, stat: avoid triggering automounts (#2044981)
- make `df --direct` work again (#2058686) - make `df --direct` work again (#2058686)