!70 回合上游社区补丁,修复异常场景下 readline 模块 crash 问题

From: @licihua 
Reviewed-by: @zhujianwei001 
Signed-off-by: @zhujianwei001
This commit is contained in:
openeuler-ci-bot 2022-10-31 01:00:06 +00:00 committed by Gitee
commit 201d196815
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From a99d905216cc0aac5de0c3050f4afc54e21c6bc5 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 5 Oct 2022 10:37:38 -0400
Subject: [PATCH] Bash-5.2 patch 2: fix crash in readline when started with an
invalid locale specification
---
lib/readline/nls.c | 8 +++++++-
patchlevel.h | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/readline/nls.c b/lib/readline/nls.c
index d2f67e0..5d1cd19 100644
--- a/lib/readline/nls.c
+++ b/lib/readline/nls.c
@@ -56,6 +56,8 @@
static int utf8locale PARAMS((char *));
+#define RL_DEFAULT_LOCALE "C"
+
#if !defined (HAVE_SETLOCALE)
/* A list of legal values for the LANG or LC_CTYPE environment variables.
If a locale name in this list is the value for the LC_ALL, LC_CTYPE,
@@ -136,7 +138,11 @@ _rl_init_locale (void)
if (lspec == 0)
lspec = "";
ret = setlocale (LC_CTYPE, lspec); /* ok, since it does not change locale */
-
+ if (ret == 0 || *ret == 0)
+ ret = setlocale (LC_CTYPE, (char *)NULL);
+ if (ret == 0 || *ret == 0)
+ ret = RL_DEFAULT_LOCALE;
+
_rl_utf8locale = (ret && *ret) ? utf8locale (ret) : 0;
return ret;
diff --git a/patchlevel.h b/patchlevel.h
index 10fde2e..17586ff 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 8
+#define PATCHLEVEL 9
#endif /* _PATCHLEVEL_H_ */
--
2.35.1

View File

@ -1,6 +1,6 @@
Name: bash Name: bash
Version: 5.1.8 Version: 5.1.8
Release: 4 Release: 5
Summary: It is the Bourne Again Shell Summary: It is the Bourne Again Shell
License: GPLv3 License: GPLv3
URL: https://www.gnu.org/software/bash URL: https://www.gnu.org/software/bash
@ -24,6 +24,7 @@ Patch137: bugfix-Forbidden-non-root-user-to-clear-history.patch
Patch138: enable-dot-logout-and-source-bashrc-through-ssh.patch Patch138: enable-dot-logout-and-source-bashrc-through-ssh.patch
Patch139: cd-alias.patch Patch139: cd-alias.patch
Patch140: bash-5.1-sw.patch Patch140: bash-5.1-sw.patch
Patch141: backport-fix-crash-in-readline-when-started-with-an-invalid.patch
BuildRequires: gcc bison texinfo autoconf ncurses-devel BuildRequires: gcc bison texinfo autoconf ncurses-devel
# Required for bash tests # Required for bash tests
@ -117,6 +118,12 @@ make check
%exclude %{_infodir}/dir %exclude %{_infodir}/dir
%changelog %changelog
* Sat Oct 29 2022 licihua <licihua@huawei.com> -5.1.8-5
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: fix crash in readline when started with an invalid locale specification
* Mon Aug 15 2022 panxiaohe <panxh.life@foxmail.com> - 5.1.8-4 * Mon Aug 15 2022 panxiaohe <panxh.life@foxmail.com> - 5.1.8-4
- fix bugfix-Forbidden-non-root-user-to-clear-history.patch - fix bugfix-Forbidden-non-root-user-to-clear-history.patch