From 4192930b426e1d0aa5282f5df229c5ff719d8d07 Mon Sep 17 00:00:00 2001 From: fly_fzc <2385803914@qq.com> Date: Mon, 3 Nov 2025 15:51:00 +0800 Subject: [PATCH] backport upstream patches --- ...tra-copy-of-function-bodies-fix-some.patch | 72 +++++++++++++++++++ ...-uncovered-by-address-sanitizer-work.patch | 46 ++++++++++++ bash.spec | 9 ++- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 backport-avoid-storing-extra-copy-of-function-bodies-fix-some.patch create mode 100644 backport-fix-minor-errors-uncovered-by-address-sanitizer-work.patch diff --git a/backport-avoid-storing-extra-copy-of-function-bodies-fix-some.patch b/backport-avoid-storing-extra-copy-of-function-bodies-fix-some.patch new file mode 100644 index 0000000..ecd8727 --- /dev/null +++ b/backport-avoid-storing-extra-copy-of-function-bodies-fix-some.patch @@ -0,0 +1,72 @@ +From dbb48b978671394bcb33c9f34656a9aadf40a318 Mon Sep 17 00:00:00 2001 +From: Chet Ramey +Date: Tue, 4 Jun 2024 12:23:18 -0400 +Subject: [PATCH] avoid storing extra copy of function bodies; fix some minor + memory leaks + +--- + parse.y | 13 +++++++++++-- + 1 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/parse.y b/parse.y +index 1349480b..eb83af4c 100644 +--- a/parse.y ++++ b/parse.y +@@ -1103,6 +1103,7 @@ coproc: COPROC shell_command + { + $$ = make_coproc_command ($2->word, $3); + $$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL; ++ dispose_word ($2); + } + | COPROC WORD shell_command redirection_list + { +@@ -1120,6 +1121,7 @@ coproc: COPROC shell_command + tc->redirects = $4; + $$ = make_coproc_command ($2->word, $3); + $$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL; ++ dispose_word ($2); + } + | COPROC simple_command + { +@@ -3518,14 +3520,19 @@ read_token (command) + #if defined (COND_COMMAND) + if ((parser_state & (PST_CONDCMD|PST_CONDEXPR)) == PST_CONDCMD) + { ++ COMMAND *cond_command; + cond_lineno = line_number; + parser_state |= PST_CONDEXPR; +- yylval.command = parse_cond_command (); ++ cond_command = parse_cond_command (); + if (cond_token != COND_END) + { + cond_error (); ++ if (cond_token == WORD) ++ dispose_word (yylval.word); ++ dispose_command (cond_command); + return (-1); + } ++ yylval.command = cond_command; + token_to_read = COND_END; + parser_state &= ~(PST_CONDEXPR|PST_CONDCMD); + return (COND_CMD); +@@ -5042,7 +5049,7 @@ cond_term () + else if (tok == BANG || (tok == WORD && (yylval.word->word[0] == '!' && yylval.word->word[1] == '\0'))) + { + if (tok == WORD) +- dispose_word (yylval.word); /* not needed */ ++ dispose_word (yylval.word); /* word not needed */ + term = cond_term (); + if (term) + term->flags ^= CMD_INVERT_RETURN; +@@ -5118,6 +5125,8 @@ cond_term () + else + parser_error (line_number, _("conditional binary operator expected")); + dispose_cond_node (tleft); ++ if (tok == WORD) ++ dispose_word (yylval.word); + COND_RETURN_ERROR (); + } + +-- +2.33.0 + diff --git a/backport-fix-minor-errors-uncovered-by-address-sanitizer-work.patch b/backport-fix-minor-errors-uncovered-by-address-sanitizer-work.patch new file mode 100644 index 0000000..65989f3 --- /dev/null +++ b/backport-fix-minor-errors-uncovered-by-address-sanitizer-work.patch @@ -0,0 +1,46 @@ +From 9cea457aef3c406893c345ade1fed7add8c536ba Mon Sep 17 00:00:00 2001 +From: Chet Ramey +Date: Tue, 28 May 2024 09:19:03 -0400 +Subject: [PATCH] fix minor errors uncovered by address sanitizer; work around + android issue with read -e -u; fix minor memory leaks; make + spell-correct-shellword work with negative arguments; fix readline + change-case on invalid multibyte character + +--- + bashline.c | 13 +++++++++++-- + 1 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/bashline.c b/bashline.c +index b638e001..9cdd9bc4 100644 +--- a/bashline.c ++++ b/bashline.c +@@ -2002,6 +2036,12 @@ command_word_completion_function (hint_text, state) + glob_matches = (char **)NULL; + } + ++ if (directory_part) ++ { ++ free (directory_part); ++ directory_part = (char *)NULL; ++ } ++ + globpat = completion_glob_pattern ((char *)hint_text); + + /* If this is an absolute program name, do not check it against +@@ -2451,8 +2491,11 @@ command_subst_completion_function (text, state) + rl_completion_suppress_quote = 1; + start_len = text - orig_start; + filename_text = savestring (text); +- if (matches) +- free (matches); ++ if (matches) ++ { ++ strvec_dispose (matches); ++ matches = (char **)NULL; ++ } + + /* + * At this point we can entertain the idea of re-parsing +-- +2.33.0 + diff --git a/bash.spec b/bash.spec index 04019ee..ec28fe7 100644 --- a/bash.spec +++ b/bash.spec @@ -2,7 +2,7 @@ Name: bash Version: 5.2.37 -Release: 7 +Release: 8 Summary: It is the Bourne Again Shell License: GPL-3.0-or-later URL: https://www.gnu.org/software/bash @@ -43,6 +43,8 @@ Patch6013: backport-fourth-set-of-ANSI-C-changes-size_t-rest-globskipdot.patch Patch6014: backport-documentation-updates-fix-for-null-commands-with-red.patch Patch6015: backport-fix-for-readline-redisplay-issue-in-C-locale-fix-for.patch Patch6016: backport-fixes-for-glibc-time-gettimeofday-issue-fix-issue-wi.patch +Patch6017: backport-fix-minor-errors-uncovered-by-address-sanitizer-work.patch +Patch6018: backport-avoid-storing-extra-copy-of-function-bodies-fix-some.patch %if %{enable_safecheck} Patch9000: only-scripts-verified-by-execveat-are-allowed-to-run.patch @@ -175,6 +177,11 @@ make check %exclude %{_infodir}/dir %changelog +* Mon Nov 3 2025 fuanan - 5.2.37-8 +- sync patches from bash community: + add backport-fix-minor-errors-uncovered-by-address-sanitizer-work.patch + add backport-avoid-storing-extra-copy-of-function-bodies-fix-some.patch + * Tue Sep 16 2025 fuanan - 5.2.37-7 - fix issue with history file containing one line too few if saving timestamps -- Gitee