Skip to content

Commit fdaf7da

Browse files
authored
readline: add patch to fix crash when readline is started with an invalid locale specification (#12903)
readline 8.2 would crash when _rl_init_locale is called with an invalid locale specification (e.g locale not available in the system). This causes a problem in initramfs emergency shell because it was not packaged with the preferred locale (C.UTF-8), thus bash will crash and no emergency shell is available. This issue does not affect Mariner 2 as it is using readline 8.1, and the bug seems to be introduced by version 8.2. Backport patch to address readline 8.2 crash when started with an invalid locale specification. Signed-off-by: Thien Trung Vuong <tvuong@microsoft.com>
1 parent c7a5b79 commit fdaf7da

6 files changed

Lines changed: 61 additions & 12 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 7274faabe97ce53d6b464272d7e6ab6c1392837b Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 5 Oct 2022 10:41:16 -0400
4+
Subject: Readline-8.2 patch 1: fix crash when readline is started with an
5+
invalid locale specification
6+
7+
---
8+
._.gitignore | Bin 4096 -> 0 bytes
9+
nls.c | 4 ++++
10+
patchlevel | 2 +-
11+
3 files changed, 5 insertions(+), 1 deletion(-)
12+
delete mode 100644 ._.gitignore
13+
14+
diff --git a/._.gitignore b/._.gitignore
15+
deleted file mode 100644
16+
index aa90ec6..0000000
17+
Binary files a/._.gitignore and /dev/null differ
18+
diff --git a/nls.c b/nls.c
19+
index 5c6a13b..8c027d6 100644
20+
--- a/nls.c
21+
+++ b/nls.c
22+
@@ -141,6 +141,10 @@ _rl_init_locale (void)
23+
if (lspec == 0)
24+
lspec = "";
25+
ret = setlocale (LC_CTYPE, lspec); /* ok, since it does not change locale */
26+
+ if (ret == 0 || *ret == 0)
27+
+ ret = setlocale (LC_CTYPE, (char *)NULL);
28+
+ if (ret == 0 || *ret == 0)
29+
+ ret = RL_DEFAULT_LOCALE;
30+
#else
31+
ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
32+
#endif
33+
diff --git a/patchlevel b/patchlevel
34+
index d8c9df7..fdf4740 100644
35+
--- a/patchlevel
36+
+++ b/patchlevel
37+
@@ -1,3 +1,3 @@
38+
# Do not edit -- exists only for use by patch
39+
40+
-0
41+
+1
42+
--
43+
cgit v1.1
44+

SPECS/readline/readline.spec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Command-line editing and history capabilities
22
Name: readline
33
Version: 8.2
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: GPLv3+
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -11,6 +11,8 @@ Source0: https://ftp.gnu.org/gnu/readline/%{name}-%{version}.tar.gz
1111
BuildRequires: ncurses-devel
1212
Requires: ncurses-libs
1313

14+
Patch: readline-8.2-patch-1.patch
15+
1416
%description
1517
The Readline package is a set of libraries that offers command-line
1618
editing and history capabilities.
@@ -23,7 +25,7 @@ Requires: %{name} = %{version}
2325
It contains the libraries and header files to create applications
2426

2527
%prep
26-
%setup -q
28+
%autosetup -p1
2729
sed -i '/MV.*old/d' Makefile.in
2830
sed -i '/{OLDSUFF}/c:' support/shlib-install
2931

@@ -109,6 +111,9 @@ make %{?_smp_mflags} check
109111
%{_libdir}/pkgconfig/history.pc
110112

111113
%changelog
114+
* Tue Mar 11 2025 Thien Trung Vuong <tvuong@microsoft.com> - 8.2-2
115+
- Add patch to fix readline crash when initialized with an invalid locale specification
116+
112117
* Mon Oct 16 2023 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 8.2-1
113118
- Auto-upgrade to 8.2 - Azure Linux 3.0 - package upgrades
114119

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ ncurses-compat-6.4-2.azl3.aarch64.rpm
3939
ncurses-devel-6.4-2.azl3.aarch64.rpm
4040
ncurses-libs-6.4-2.azl3.aarch64.rpm
4141
ncurses-term-6.4-2.azl3.aarch64.rpm
42-
readline-8.2-1.azl3.aarch64.rpm
43-
readline-devel-8.2-1.azl3.aarch64.rpm
42+
readline-8.2-2.azl3.aarch64.rpm
43+
readline-devel-8.2-2.azl3.aarch64.rpm
4444
libattr-2.5.2-1.azl3.aarch64.rpm
4545
attr-2.5.2-1.azl3.aarch64.rpm
4646
libacl-2.3.1-2.azl3.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ ncurses-compat-6.4-2.azl3.x86_64.rpm
3939
ncurses-devel-6.4-2.azl3.x86_64.rpm
4040
ncurses-libs-6.4-2.azl3.x86_64.rpm
4141
ncurses-term-6.4-2.azl3.x86_64.rpm
42-
readline-8.2-1.azl3.x86_64.rpm
43-
readline-devel-8.2-1.azl3.x86_64.rpm
42+
readline-8.2-2.azl3.x86_64.rpm
43+
readline-devel-8.2-2.azl3.x86_64.rpm
4444
libattr-2.5.2-1.azl3.x86_64.rpm
4545
attr-2.5.2-1.azl3.x86_64.rpm
4646
libacl-2.3.1-2.azl3.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ python3-setuptools-69.0.3-4.azl3.noarch.rpm
557557
python3-test-3.12.9-1.azl3.aarch64.rpm
558558
python3-tools-3.12.9-1.azl3.aarch64.rpm
559559
python3-wheel-0.43.0-1.azl3.noarch.rpm
560-
readline-8.2-1.azl3.aarch64.rpm
561-
readline-debuginfo-8.2-1.azl3.aarch64.rpm
562-
readline-devel-8.2-1.azl3.aarch64.rpm
560+
readline-8.2-2.azl3.aarch64.rpm
561+
readline-debuginfo-8.2-2.azl3.aarch64.rpm
562+
readline-devel-8.2-2.azl3.aarch64.rpm
563563
rpm-4.18.2-1.azl3.aarch64.rpm
564564
rpm-build-4.18.2-1.azl3.aarch64.rpm
565565
rpm-build-libs-4.18.2-1.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,9 @@ python3-setuptools-69.0.3-4.azl3.noarch.rpm
565565
python3-test-3.12.9-1.azl3.x86_64.rpm
566566
python3-tools-3.12.9-1.azl3.x86_64.rpm
567567
python3-wheel-0.43.0-1.azl3.noarch.rpm
568-
readline-8.2-1.azl3.x86_64.rpm
569-
readline-debuginfo-8.2-1.azl3.x86_64.rpm
570-
readline-devel-8.2-1.azl3.x86_64.rpm
568+
readline-8.2-2.azl3.x86_64.rpm
569+
readline-debuginfo-8.2-2.azl3.x86_64.rpm
570+
readline-devel-8.2-2.azl3.x86_64.rpm
571571
rpm-4.18.2-1.azl3.x86_64.rpm
572572
rpm-build-4.18.2-1.azl3.x86_64.rpm
573573
rpm-build-libs-4.18.2-1.azl3.x86_64.rpm

0 commit comments

Comments
 (0)