bash: update to 5.3 patch level 12

- Fix loop in subshells calling wait builtin with inherited job list
- Fix mapfile problem when callback unsets the variable it is modifying
- Fix subshells inappropriately running the EXIT trap if they receive a
  fatal signal before resetting traps

Signed-off-by: Wei-Ting Yang <williamatcg@gmail.com>
(cherry picked from commit 3085718815)
This commit is contained in:
Wei-Ting Yang authored and Josef Schlehofer committed 2026-06-09 22:10:04 +02:00
1 parent 63c84107be
commit 9907cd7eb6
14 files changed
+121 -1

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=bash
PKG_VERSION:=5.3
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@GNU/bash
@@ -0,0 +1,27 @@
From d129c77127233051b8235cbec0cff1d6bea1f5f1 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 3 Jun 2026 10:19:04 -0400
Subject: Bash-5.3 patch 10: fix loop in subshells calling wait builtin with
inherited job list
--- a/jobs.c
+++ b/jobs.c
@@ -2839,7 +2839,7 @@ wait_for_background_pids (struct procsta
ps->pid = pid;
ps->status = (r < 0 || r > 256) ? 127 : r;
}
- if (r == -1 && errno == ECHILD)
+ if ((r < 0 || r > 256) && errno == ECHILD)
{
/* If we're mistaken about job state, compensate. */
check_async = 0;
--- 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 9
+#define PATCHLEVEL 10
#endif /* _PATCHLEVEL_H_ */
@@ -0,0 +1,45 @@
From eb9d01914bb2320faaa8bad68859da449884744c Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 3 Jun 2026 10:20:22 -0400
Subject: Bash-5.3 patch 11: fix mapfile problem when callback unsets the
variable it is modifying
--- a/builtins/mapfile.def
+++ b/builtins/mapfile.def
@@ -153,9 +153,7 @@ mapfile (int fd, long line_count_goal, l
line_length = 0;
unbuffered_read = 0;
- /* The following check should be done before reading any lines. Doing it
- here allows us to call bind_array_element instead of bind_array_variable
- and skip the variable lookup on every call. */
+ /* The following check should be done before reading any lines. */
entry = builtin_find_indexed_array (array_name, flags & MAPF_CLEARARRAY);
if (entry == 0)
return EXECUTION_FAILURE;
@@ -201,8 +199,13 @@ mapfile (int fd, long line_count_goal, l
run_callback (callback, array_index, line);
}
- /* XXX - bad things can happen if the callback modifies ENTRY, e.g.,
- unsetting it or changing it to a non-indexed-array type. */
+ /* Bad things can happen if the callback modifies ENTRY, e.g.,
+ unsetting it or changing it to a non-indexed-array type, so we
+ look it up again every time we need to assign something */
+ entry = bind_array_variable (array_name, array_index, line, 0);
+ if (entry == 0 || ASSIGN_DISALLOWED (entry, 0))
+ return EXECUTION_FAILURE;
+
bind_array_element (entry, array_index, line, 0);
/* Have we exceeded # of lines to store? */
--- 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 10
+#define PATCHLEVEL 11
#endif /* _PATCHLEVEL_H_ */
@@ -0,0 +1,48 @@
From ecb2456d6357bfd3b2965aafe2f2021d1ced5b72 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 3 Jun 2026 10:21:45 -0400
Subject: Bash-5.3 patch 12: fix subshells inappropriately running the EXIT
trap if they receive a fatal signal before resetting traps
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -1643,13 +1643,13 @@ execute_in_subshell (COMMAND *command, i
if (user_subshell)
{
- subshell_environment = SUBSHELL_PAREN; /* XXX */
+ subshell_environment = SUBSHELL_PAREN|SUBSHELL_IGNTRAP; /* XXX */
if (asynchronous)
subshell_environment |= SUBSHELL_ASYNC;
}
else
{
- subshell_environment = 0; /* XXX */
+ subshell_environment = SUBSHELL_IGNTRAP; /* XXX */
if (asynchronous)
subshell_environment |= SUBSHELL_ASYNC;
if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
--- 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 11
+#define PATCHLEVEL 12
#endif /* _PATCHLEVEL_H_ */
--- a/sig.c
+++ b/sig.c
@@ -638,7 +638,10 @@ termsig_handler (int sig)
interrupt_execution = retain_fifos = executing_funsub = 0;
comsub_ignore_return = return_catch_flag = wait_intr_flag = 0;
- run_exit_trap (); /* XXX - run exit trap possibly in signal context? */
+ /* Don't run the exit trap if we're supposed to be ignoring traps in a
+ subshell environment. */
+ if ((subshell_environment & SUBSHELL_IGNTRAP) == 0)
+ run_exit_trap (); /* XXX - run exit trap possibly in signal context? */
kill_shell (sig);
}