Compare commits

..

No commits in common. "dd44390f1965874dabb0b981bb283bfd8c989554" and "319dadfdbf95abd5fe8779ea639a5b59c0474ea1" have entirely different histories.

7 changed files with 37 additions and 542 deletions

View File

@ -1,31 +0,0 @@
From b1764f8226260d5b58958d613c7654f01e624dca Mon Sep 17 00:00:00 2001
From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
Date: Mon, 3 Jun 2024 16:49:46 +0800
Subject: [PATCH] Fix a performance regression while using large number of
environment variables
Resolves: RHEL-20020
Signed-off-by: Siteshwar Vashisht <svashisht@redhat.com>
---
execute_cmd.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/execute_cmd.c b/execute_cmd.c
index 71d147c..2e33722 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -5482,11 +5482,7 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
{
/* If we're optimizing out the fork (implicit `exec'), decrement the
shell level like `exec' would do. */
-#if 0 /* TAG: bash-5.2 psmith 10/11/2020 */
if (nofork && pipe_in == NO_PIPE && pipe_out == NO_PIPE && (subshell_environment & SUBSHELL_PIPE) == 0)
-#else
- if (nofork && pipe_in == NO_PIPE && pipe_out == NO_PIPE)
-#endif
adjust_shell_level (-1);
maybe_make_export_env ();
--
2.33.0

View File

@ -1,40 +0,0 @@
From 2610d40b32301cd7256bf1dfc49c9f8bfe0dcd53 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 28 Aug 2024 11:42:10 -0400
Subject: [PATCH] documentation updates; fix for null commands with redirection
expansion errors; changes to job notifications for interactive shells
sourcing files; fix underflow issue with word_top
Conflict:only the modified content of execute_cmd.c is rounded.
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=2610d40b32301cd7256bf1dfc49c9f8bfe0dcd53
---
execute_cmd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/execute_cmd.c b/execute_cmd.c
index 71d147c..905adc5 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -4001,7 +4001,7 @@ execute_null_command (redirects, pipe_in, pipe_out, async)
REDIRECT *redirects;
int pipe_in, pipe_out, async;
{
- int r;
+ int r, code;
int forcefork, fork_flags;
REDIRECT *rd;
@@ -4036,6 +4036,10 @@ execute_null_command (redirects, pipe_in, pipe_out, async)
if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
subshell_environment |= SUBSHELL_PIPE;
+ code = setjmp_nosigs (top_level);
+ if (code)
+ exit (EXECUTION_FAILURE);
+
if (do_redirections (redirects, RX_ACTIVE) == 0)
exit (EXECUTION_SUCCESS);
else
--
2.33.0

View File

@ -1,237 +0,0 @@
From 35465406cdae9cd4a15e7f6699e657b5d09bf7bd Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Fri, 2 Feb 2024 14:39:50 -0500
Subject: [PATCH] fix for cd when curent directory doesn't exist; fix wait -n
in posix mode to delete any job that it returns; fix some variables where
readonly can be circumvented; fix some overflows in printf
Conflict:only the modified content of builtins/printf.def is rounded. The bindflags variable in the upstream community patch does not exist, so 0 is used instead of bindflags, which is consistent with the current version
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=35465406cdae9cd4a15e7f6699e657b5d09bf7bd
---
builtins/printf.def | 122 +++++++++++++++++++++++---------------------
1 file changed, 65 insertions(+), 57 deletions(-)
diff --git a/builtins/printf.def b/builtins/printf.def
index 0a5f489..b2d1094 100644
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -1,7 +1,7 @@
This file is printf.def, from which is created printf.c.
It implements the builtin "printf" in Bash.
-Copyright (C) 1997-2020 Free Software Foundation, Inc.
+Copyright (C) 1997-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -107,6 +107,50 @@ $END
extern int errno;
#endif
+/* We free the buffer used by mklong() if it's `too big'. */
+#define PRETURN(value) \
+ do \
+ { \
+ QUIT; \
+ retval = value; \
+ if (conv_bufsize > 4096 ) \
+ { \
+ free (conv_buf); \
+ conv_bufsize = 0; \
+ conv_buf = 0; \
+ } \
+ if (vflag) \
+ { \
+ SHELL_VAR *v; \
+ v = builtin_bind_variable (vname, vbuf, 0); \
+ stupidly_hack_special_variables (vname); \
+ if (v == 0 || readonly_p (v) || noassign_p (v)) \
+ retval = EXECUTION_FAILURE; \
+ if (vbsize > 4096) \
+ { \
+ free (vbuf); \
+ vbsize = 0; \
+ vbuf = 0; \
+ } \
+ else if (vbuf) \
+ vbuf[0] = 0; \
+ } \
+ else \
+ { \
+ if (ferror (stdout) == 0) \
+ fflush (stdout); \
+ QUIT; \
+ if (ferror (stdout)) \
+ { \
+ sh_wrerror (); \
+ clearerr (stdout); \
+ retval = EXECUTION_FAILURE; \
+ } \
+ } \
+ return (retval); \
+ } \
+ while (0)
+
#define PC(c) \
do { \
char b[2]; \
@@ -122,7 +166,9 @@ extern int errno;
#define PF(f, func) \
do { \
int nw; \
- clearerr (stdout); \
+ if (vflag == 0) \
+ clearerr (stdout); \
+ errno = 0; \
if (have_fieldwidth && have_precision) \
nw = vflag ? vbprintf (f, fieldwidth, precision, func) : printf (f, fieldwidth, precision, func); \
else if (have_fieldwidth) \
@@ -131,56 +177,17 @@ extern int errno;
nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \
else \
nw = vflag ? vbprintf (f, func) : printf (f, func); \
- tw += nw; \
- QUIT; \
- if (ferror (stdout)) \
+ if (nw < 0 || ferror (stdout)) \
{ \
- sh_wrerror (); \
- clearerr (stdout); \
- return (EXECUTION_FAILURE); \
+ QUIT; \
+ if (vflag) \
+ builtin_error ("%s", strerror (errno)); \
+ PRETURN (EXECUTION_FAILURE); \
} \
+ tw += nw; \
+ QUIT; \
} while (0)
-/* We free the buffer used by mklong() if it's `too big'. */
-#define PRETURN(value) \
- do \
- { \
- QUIT; \
- if (vflag) \
- { \
- SHELL_VAR *v; \
- v = builtin_bind_variable (vname, vbuf, 0); \
- stupidly_hack_special_variables (vname); \
- if (v == 0 || readonly_p (v) || noassign_p (v)) \
- return (EXECUTION_FAILURE); \
- } \
- if (conv_bufsize > 4096 ) \
- { \
- free (conv_buf); \
- conv_bufsize = 0; \
- conv_buf = 0; \
- } \
- if (vbsize > 4096) \
- { \
- free (vbuf); \
- vbsize = 0; \
- vbuf = 0; \
- } \
- else if (vbuf) \
- vbuf[0] = 0; \
- if (ferror (stdout) == 0) \
- fflush (stdout); \
- QUIT; \
- if (ferror (stdout)) \
- { \
- sh_wrerror (); \
- clearerr (stdout); \
- return (EXECUTION_FAILURE); \
- } \
- return (value); \
- } \
- while (0)
-
#define SKIP1 "#'-+ 0"
#define LENMODS "hjlLtz"
@@ -228,7 +235,7 @@ static int conversion_error;
static int vflag = 0;
static char *vbuf, *vname;
static size_t vbsize;
-static int vblen;
+static size_t vblen;
static intmax_t tw;
@@ -305,6 +312,7 @@ printf_builtin (list)
return ((v == 0 || readonly_p (v) || noassign_p (v)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
+ /* If the format string is empty after preprocessing, return immediately. */
if (list->word->word == 0 || list->word->word[0] == '\0')
return (EXECUTION_SUCCESS);
@@ -313,10 +321,6 @@ printf_builtin (list)
garglist = orig_arglist = list->next;
- /* If the format string is empty after preprocessing, return immediately. */
- if (format == 0 || *format == 0)
- return (EXECUTION_SUCCESS);
-
/* Basic algorithm is to scan the format string for conversion
specifications -- once one is found, find out if the field
width or precision is a '*'; if it is, gather up value. Note,
@@ -681,7 +685,7 @@ printf_builtin (list)
modstart[1] = nextch;
}
- if (ferror (stdout))
+ if (vflag == 0 && ferror (stdout))
{
/* PRETURN will print error message. */
PRETURN (EXECUTION_FAILURE);
@@ -811,7 +815,7 @@ printstr (fmt, string, len, fieldwidth, precision)
for (; padlen < 0; padlen++)
PC (' ');
- return (ferror (stdout) ? -1 : 0);
+ return ((vflag == 0 && ferror (stdout)) ? -1 : 0);
}
/* Convert STRING by expanding the escape sequences specified by the
@@ -1029,7 +1033,7 @@ vbadd (buf, blen)
#ifdef DEBUG
if (strlen (vbuf) != vblen)
- internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
+ internal_error ("printf:vbadd: vblen (%zu) != strlen (vbuf) (%zu)", vblen, strlen (vbuf));
#endif
return vbuf;
@@ -1051,6 +1055,8 @@ vbprintf (format, va_alist)
SH_VA_START (args, format);
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
va_end (args);
+ if (blen < 0)
+ return (blen);
nlen = vblen + blen + 1;
if (nlen >= vbsize)
@@ -1060,6 +1066,8 @@ vbprintf (format, va_alist)
SH_VA_START (args, format);
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
va_end (args);
+ if (blen < 0)
+ return (blen);
}
vblen += blen;
@@ -1067,7 +1075,7 @@ vbprintf (format, va_alist)
#ifdef DEBUG
if (strlen (vbuf) != vblen)
- internal_error ("printf:vbprintf: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
+ internal_error ("printf:vbprintf: vblen (%zu) != strlen (vbuf) (%zu)", vblen, strlen (vbuf));
#endif
return (blen);
--
2.33.0

View File

@ -1,33 +0,0 @@
From b116cfe57df2c061cd953b77a0fc1b738dd5fe94 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Fri, 8 Nov 2024 11:13:57 -0500
Subject: [PATCH] fix for readline redisplay issue in C locale; fix for small
memory leak in termcap replacement library; updates to formatted
documentation; fix problem with distclean and y.tab.h; Makefile clean targets
updates
Conflict:only the modified content of lib/termcap/termcap.c is rounded.
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=b116cfe57df2c061cd953b77a0fc1b738dd5fe94
---
lib/termcap/termcap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/termcap/termcap.c b/lib/termcap/termcap.c
index ba3dab2..012cd44 100644
--- a/lib/termcap/termcap.c
+++ b/lib/termcap/termcap.c
@@ -533,7 +533,10 @@ tgetent (bp, name)
fd = open (termcap_name, O_RDONLY, 0);
#endif
if (fd < 0)
- return -1;
+ {
+ free (indirect);
+ return -1;
+ }
buf.size = BUFSIZE;
/* Add 1 to size to ensure room for terminating null. */
--
2.33.0

View File

@ -1,29 +0,0 @@
From 5114e17172276cf5a2f889f8037ae58c4cb05bb9 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Mon, 30 Dec 2024 10:45:14 -0500
Subject: [PATCH] fix issue with failed history expansion changing the history
list offset; fix some tests to avoid problems with error messages that differ
between systems; fix issue with readline rl_abort not clearing any pending
command to execute
Conflict:only the modified content of lib/readline/util.c is rounded.
---
lib/readline/util.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/readline/util.c b/lib/readline/util.c
index 1576b55..e869ed1 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -111,6 +111,7 @@ _rl_abort_internal (void)
RL_UNSETSTATE (RL_STATE_MULTIKEY); /* XXX */
rl_last_func = (rl_command_func_t *)NULL;
+ _rl_command_to_execute = 0;
_rl_longjmp (_rl_top_level, 1);
return (0);
--
2.33.0

View File

@ -1,142 +0,0 @@
From 0390b4354a9e5df517ef2d4f9d78a099063b22b4 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 28 Jan 2025 10:15:16 -0500
Subject: [PATCH] posix change for undoing redirections after failed exec;
change readline to set lines and columns after SIGTSTP/SIGCONT
Conflict:only the modified content of builtins/exec.def and execute_cmd.c is rounded.
---
builtins/exec.def | 11 +++++-----
execute_cmd.c | 56 +++++++++++++++++++++++++++++++----------------
2 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/builtins/exec.def b/builtins/exec.def
index cbcb641..ee4921f 100644
--- a/builtins/exec.def
+++ b/builtins/exec.def
@@ -129,12 +129,13 @@ exec_builtin (list)
}
list = loptend;
- /* First, let the redirections remain. */
- dispose_redirects (redirection_undo_list);
- redirection_undo_list = (REDIRECT *)NULL;
-
+ /* First, let the redirections remain if exec is called without operands */
if (list == 0)
- return (EXECUTION_SUCCESS);
+ {
+ dispose_redirects (redirection_undo_list);
+ redirection_undo_list = (REDIRECT *)NULL;
+ return (EXECUTION_SUCCESS);
+ }
#if defined (RESTRICTED_SHELL)
if (restricted)
diff --git a/execute_cmd.c b/execute_cmd.c
index 9adb9cb..82ad27d 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -5292,7 +5292,7 @@ execute_builtin_or_function (words, builtin, var, redirects,
struct fd_bitmap *fds_to_close;
int flags;
{
- int result;
+ int result, has_exec_redirects;
REDIRECT *saved_undo_list;
#if defined (PROCESS_SUBSTITUTION)
int ofifo, nfifo, osize;
@@ -5319,17 +5319,25 @@ execute_builtin_or_function (words, builtin, var, redirects,
return (EX_REDIRFAIL); /* was EXECUTION_FAILURE */
}
+ /* Is this the exec builtin with redirections? We want to undo them and
+ throw away the exec_redirection_undo_list if exec has a program name
+ argument, fails to execute it, and does not exit the shell */
+ has_exec_redirects = (builtin == exec_builtin) && redirection_undo_list;
+
saved_undo_list = redirection_undo_list;
/* Calling the "exec" builtin changes redirections forever. */
if (builtin == exec_builtin)
{
- dispose_redirects (saved_undo_list);
+ /* let exec_builtin handle disposing redirection_undo_list */
saved_undo_list = exec_redirection_undo_list;
exec_redirection_undo_list = (REDIRECT *)NULL;
}
else
- dispose_exec_redirects ();
+ {
+ dispose_exec_redirects ();
+ redirection_undo_list = (REDIRECT *)NULL;
+ }
if (saved_undo_list)
{
@@ -5337,8 +5345,6 @@ execute_builtin_or_function (words, builtin, var, redirects,
add_unwind_protect (cleanup_redirects, (char *)saved_undo_list);
}
- redirection_undo_list = (REDIRECT *)NULL;
-
if (builtin)
result = execute_builtin (builtin, words, flags, 0);
else
@@ -5350,26 +5356,38 @@ execute_builtin_or_function (words, builtin, var, redirects,
if (ferror (stdout))
clearerr (stdout);
- /* If we are executing the `command' builtin, but this_shell_builtin is
- set to `exec_builtin', we know that we have something like
- `command exec [redirection]', since otherwise `exec' would have
- overwritten the shell and we wouldn't get here. In this case, we
- want to behave as if the `command' builtin had not been specified
- and preserve the redirections. */
- if (builtin == command_builtin && this_shell_builtin == exec_builtin)
+ if (has_exec_redirects && redirection_undo_list)
{
- int discard;
-
- discard = 0;
+ /* We have returned from the exec builtin. If redirection_undo_list is
+ still non-null, we had an operand and failed to exit the shell for
+ some reason. We want to dispose of saved_undo_list, discard the frame,
+ and let the redirections be undone as usual. If redirection_undo_list
+ is NULL, then exec_builtin had no program name operand and disposed
+ of it. In that case, we should perform the redirections in
+ exec_redirection_undo_list (saved_undo_list) like usual. */
+ if (saved_undo_list)
+ {
+ dispose_redirects (saved_undo_list); /* exec_redirection_undo_list */
+ discard_unwind_frame ("saved-redirects");
+ }
+ saved_undo_list = exec_redirection_undo_list = (REDIRECT *)NULL;
+ }
+ /* This code is no longer executed and remains only for explanatory reasons. */
+ else if (builtin == command_builtin && this_shell_builtin == exec_builtin)
+ {
+ /* If we are executing the `command' builtin, but this_shell_builtin is
+ set to `exec_builtin', we know that we have something like
+ `command exec [redirection]', since otherwise `exec' would have
+ overwritten the shell and we wouldn't get here. In this case, we
+ want to behave as if the `command' builtin had not been specified
+ and preserve the redirections. */
if (saved_undo_list)
{
- dispose_redirects (saved_undo_list);
- discard = 1;
+ dispose_redirects (saved_undo_list); /* redirection_undo_list */
+ discard_unwind_frame ("saved-redirects");
}
redirection_undo_list = exec_redirection_undo_list;
saved_undo_list = exec_redirection_undo_list = (REDIRECT *)NULL;
- if (discard)
- discard_unwind_frame ("saved-redirects");
}
if (saved_undo_list)
--
2.33.0

View File

@ -1,6 +1,14 @@
%if %{?openEuler:1}0
%global ENABLE_RELOC 0
%endif
%if %{?ENABLE_RELOC}
%global ldflags_options -Wl,--emit-relocs
%endif
Name: bash
Version: 5.1.8
Release: 18
Release: 13
Summary: It is the Bourne Again Shell
License: GPLv3
URL: https://www.gnu.org/software/bash
@ -44,12 +52,6 @@ Patch6013: backport-changes-for-quoting-special-and-multibyte-characters.patch
Patch6014: backport-fixes-for-LINENO-in-multi-line-simple-commands-print.patch
Patch6015: backport-changes-to-SIGINT-handler-while-waiting-for-a-child-.patch
Patch6016: backport-renamed-several-functions-beginning-with-legal_-chan.patch
Patch6017: backport-fix-for-cd-when-curent-directory-doesn-t-exist-fix-w.patch
Patch6018: backport-Fix-a-performance-regression-while-using-large-numbe.patch
Patch6019: backport-documentation-updates-fix-for-null-commands-with-red.patch
Patch6020: backport-fix-for-readline-redisplay-issue-in-C-locale-fix-for.patch
Patch6021: backport-posix-change-for-undoing-redirections-after-failed-e.patch
Patch6022: backport-fix-issue-with-failed-history-expansion-changing-the.patch
BuildRequires: gcc bison texinfo autoconf ncurses-devel
# Required for bash tests
@ -74,6 +76,16 @@ Requires: pkgconf-pkg-config
%description devel
This package contains development files for %{name}.
%if %{?ENABLE_RELOC}
%package relocation
Summary: Relocations for %{name}
Requires: %{name} = %{version}-%{release}
BuildRequires: sysboost-devel
%description relocation
This package contains relocations for %{name}.
%endif
%package help
Summary: Documents for %{name}
Buildarch: noarch
@ -89,12 +101,17 @@ Man pages and other related documents for %{name}.
%build
autoconf
%configure --with-bash-malloc=no --with-afs
%configure --with-bash-malloc=no --with-afs LDFLAGS="%{?ldflags_options}"
MFLAGS="CPPFLAGS=-D_GNU_SOURCE -DRECYCLES_PIDS -DDEFAULT_PATH_VALUE='\"/usr/local/bin:/usr/bin\"' `getconf LFS_CFLAGS`"
make "$MFLAGS" version.h
make "$MFLAGS" -C builtins
%make_build "$MFLAGS"
%if %{?ENABLE_RELOC}
objreloc $RPM_BUILD_DIR/%{name}-%{version}/bash
rm -rf $RPM_BUILD_DIR/%{name}-%{version}/bash.prim
%endif
%install
%make_install install-headers
ln -sf bash %{buildroot}%{_bindir}/sh
@ -103,6 +120,11 @@ install -pDm 644 %SOURCE2 %{buildroot}/etc/skel/.bash_profile
install -pDm 644 %SOURCE3 %{buildroot}/etc/skel/.bash_logout
install -pDm 644 ./configs/alias.sh %{buildroot}%{_sysconfdir}/profile.d/alias.sh
%if %{?ENABLE_RELOC}
mkdir -p ${RPM_BUILD_ROOT}/usr/lib/relocation/%{_bindir}
install -pDm 400 $RPM_BUILD_DIR/%{name}-%{version}/bash.relocation ${RPM_BUILD_ROOT}/usr/lib/relocation/%{_bindir}/bash.relocation
%endif
# bug #820192, need to add execable alternatives for regular built-ins
for ea in alias bg cd command fc fg getopts hash jobs read type ulimit umask unalias wait
do
@ -126,6 +148,12 @@ make check
%{_bindir}/{hash,getopts,jobs,read,type,ulimit,umask,unalias}
%config(noreplace) %{_sysconfdir}/profile.d/alias.sh
%if %{?ENABLE_RELOC}
%files relocation
%defattr(-,root,root)
/usr/lib/relocation/%{_bindir}/bash.relocation
%endif
%files devel
%defattr(-,root,root)
%{_includedir}/%{name}
@ -143,27 +171,6 @@ make check
%exclude %{_infodir}/dir
%changelog
* Wed Mar 26 2025 Linux_zhang <zhangruifang@h-partners.com> - 5.1.8-18
- sync patches from bash community
* Fri Dec 13 2024 wangyuhang<wangyuhang27@huawei.com> - 5.1.8-17
- fix a coredump issue and a minor memory leak
* Mon Jun 03 2024 Zhao Mengmeng <zhaomengmeng@kylinos.cn> - 5.1.8-16
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC: Fix a performance regression while using large number of environment variables
* Fri Mar 29 2024 wangyuhang<wangyuhang27@huawei.com> - 5.1.8-15
- fix some overflows in printf
* Wed Feb 28 2024 liutie <liutie4@huawei.com> -5.1.8-14
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Relocations are no longer required.
* Wed Feb 28 2024 wangyuhang <wangyuhang27@huawei.com> -5.1.8-13
- Type:bugfix
- ID:NA
@ -376,4 +383,4 @@ make check
- DESC:1000 Forbidden non root user to clear history
* Mon Oct 08 2018 licunlong <licunlong@huawei.com> - 4.4.23-5
- Package Initialization
- Package Initialization