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 d736cafa20
commit 016c9b4368
3 changed files with 12 additions and 7 deletions

View File

@ -588,16 +588,18 @@ index 7801274..569a7ee 100644
{
/* Go back one column, and force recalculation of the
next tab stop. */
@@ -221,7 +235,7 @@ unexpand (void)
@@ -221,7 +235,9 @@ unexpand (void)
}
else
{
- column++;
+ column += mb_width (c);
+ /* mb_width() returns 0 for control characters */
+ const int width = mb_width (c);
+ column += MIN(1, width);
if (!column)
die (EXIT_FAILURE, 0, _("input line is too long"));
}
@@ -229,8 +243,11 @@ unexpand (void)
@@ -229,8 +245,11 @@ unexpand (void)
if (pending)
{
if (pending > 1 && one_blank_before_tab_stop)
@ -611,7 +613,7 @@ index 7801274..569a7ee 100644
die (EXIT_FAILURE, errno, _("write error"));
pending = 0;
one_blank_before_tab_stop = false;
@@ -240,16 +257,17 @@ unexpand (void)
@@ -240,16 +259,17 @@ unexpand (void)
convert &= convert_entire_line || blank;
}

View File

@ -21,8 +21,8 @@ index 569a7ee..3bbbd66 100644
- else
+ else if (!mb_iseq (c, '\n'))
{
column += mb_width (c);
if (!column)
/* mb_width() returns 0 for control characters */
const int width = mb_width (c);
--
2.7.4

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.32
Release: 33%{?dist}
Release: 34%{?dist}
License: GPLv3+
Url: https://www.gnu.org/software/coreutils/
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
@ -331,6 +331,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
* Mon Aug 01 2022 Kamil Dudka <kdudka@redhat.com> - 8.32-34
- prevent unexpand from failing on control characters (#2112870)
* Mon Mar 21 2022 Kamil Dudka <kdudka@redhat.com> - 8.32-33
- ls, stat: avoid triggering automounts (#2044981)