fix unexpand/expand crash on invalid multibyte characters

Resolves: RHEL-152110
This commit is contained in:
Lukáš Zaoral 2026-03-19 10:21:00 +01:00
parent a3fa3845e1
commit ba8b682fe0
No known key found for this signature in database
GPG Key ID: 39157506DD67752D
2 changed files with 8 additions and 11 deletions

View File

@ -10,7 +10,7 @@ Subject: [PATCH] coreutils-i18n.patch
lib/mbchar.c | 23 ++
lib/mbchar.h | 373 +++++++++++++++++
lib/mbfile.c | 20 +
lib/mbfile.h | 267 ++++++++++++
lib/mbfile.h | 261 ++++++++++++
m4/mbchar.m4 | 13 +
m4/mbfile.m4 | 14 +
src/cut.c | 508 +++++++++++++++++++++--
@ -34,7 +34,7 @@ Subject: [PATCH] coreutils-i18n.patch
tests/sort/sort-merge.pl | 42 ++
tests/sort/sort.pl | 40 +-
tests/unexpand/mb.sh | 173 ++++++++
30 files changed, 3606 insertions(+), 196 deletions(-)
30 files changed, 3600 insertions(+), 196 deletions(-)
create mode 100644 lib/mbchar.c
create mode 100644 lib/mbchar.h
create mode 100644 lib/mbfile.c
@ -538,10 +538,10 @@ index 0000000..8d2957b
+#include "mbfile.h"
diff --git a/lib/mbfile.h b/lib/mbfile.h
new file mode 100644
index 0000000..ad61c19
index 0000000..1ea1358
--- /dev/null
+++ b/lib/mbfile.h
@@ -0,0 +1,267 @@
@@ -0,0 +1,261 @@
+/* Multibyte character I/O: macros for multi-byte encodings.
+ Copyright (C) 2001, 2005, 2009-2023 Free Software Foundation, Inc.
+
@ -641,11 +641,7 @@ index 0000000..ad61c19
+
+ /* If mbf->state is not in an initial state, some more 32-bit wide character
+ may be hiding in the state. We need to call mbrtoc32 again. */
+ #if GNULIB_MBRTOC32_REGULAR
+ assert (mbsinit (&mbf->state));
+ #else
+ if (mbsinit (&mbf->state))
+ #endif
+ {
+ /* Before using mbrtoc32, we need at least one byte. */
+ if (new_bufcount == 0)
@ -727,7 +723,6 @@ index 0000000..ad61c19
+ }
+ else
+ {
+ #if !GNULIB_MBRTOC32_REGULAR
+ if (bytes == (size_t) -3)
+ {
+ /* The previous multibyte sequence produced an additional 32-bit
@ -736,7 +731,6 @@ index 0000000..ad61c19
+ bytes = 0;
+ }
+ else
+ #endif
+ {
+ bytes = mbf->bufcount + bytes;
+ mbf->bufcount = new_bufcount;

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 9.5
Release: 8%{?dist}
Release: 9%{?dist}
# some used parts of gnulib are under various variants of LGPL
License: GPL-3.0-or-later AND GFDL-1.3-no-invariants-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later
Url: https://www.gnu.org/software/coreutils/
@ -273,6 +273,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
* Thu Mar 19 2026 Lukáš Zaoral <lzaoral@redhat.com> - 9.5-9
- fix unexpand/expand crash on invalid multibyte characters (RHEL-152110)
* Thu Mar 19 2026 Lukáš Zaoral <lzaoral@redhat.com> - 9.5-8
- fix df/direct.sh and unexpand/mb.sh tests (RHEL-151532)