Skip to content

Commit 4e23c82

Browse files
committed
bash: update to 5.3 patch level 9
- Fix posix-mode issue with "wait -n", where it can return process IDs outside the requested set - Do not try to use shm_open, there is too much variance in behavior across systems - Remove internal quoting that causes failures when expanding nested array subscripts in an arithmetic context - Fix issue with source when read(2) returns fewer characters than fstat(2) says are available - Fix crash when restoring default disposition for SIGINT in asynchronous subshell - Fix issues with range expressions and non-ascii characters in glob patterns when globasciiranges is enabled - Fix issue where nofork command substitutions can affect redirections in the calling shell - Fix issue with calling mbrtowc too much when translating ansic-single-quoted strings - Fix crash when interrupting reverse i-search with ^C Signed-off-by: Wei-Ting Yang <williamatcg@gmail.com>
1 parent a3c5032 commit 4e23c82

10 files changed

+517
-1
lines changed

utils/bash/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=bash
1111
PKG_VERSION:=5.3
12-
PKG_RELEASE:=1
12+
PKG_RELEASE:=2
1313

1414
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
1515
PKG_SOURCE_URL:=@GNU/bash
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From 21fee8ebcf03858a4c14b605095e89333ba159ba Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 23 Jul 2025 15:42:17 -0400
4+
Subject: Bash-5.3 patch 1: fix posix-mode issue with "wait -n", where it can
5+
return process IDs outside the requested set
6+
7+
--- a/jobs.c
8+
+++ b/jobs.c
9+
@@ -3538,7 +3538,7 @@ return_procsub:
10+
/* There aren't any dead jobs in the jobs table, but let's see if there's
11+
one in bgpids. We can do this in posix mode because we'll remove any
12+
one we find from the table, preserving existing semantics. */
13+
- if (posixly_correct && (t = bgp_findone ()))
14+
+ if (posixly_correct && (flags & JWAIT_WAITING) == 0 && (t = bgp_findone ()))
15+
{
16+
pid = t->pid;
17+
r = t->status;
18+
--- a/patchlevel.h
19+
+++ b/patchlevel.h
20+
@@ -25,6 +25,6 @@
21+
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
22+
looks for to find the patch level (for the sccs version string). */
23+
24+
-#define PATCHLEVEL 0
25+
+#define PATCHLEVEL 1
26+
27+
#endif /* _PATCHLEVEL_H_ */
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
From 2ea3d6064911104d8e0437cb75b0e2559b0cd1b2 Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 23 Jul 2025 15:47:12 -0400
4+
Subject: Bash-5.3 patch 2: do not try to use shm_open, there is too much
5+
variance in behavior across systems
6+
7+
--- a/lib/sh/anonfile.c
8+
+++ b/lib/sh/anonfile.c
9+
@@ -25,7 +25,7 @@
10+
#endif
11+
#include <bashtypes.h>
12+
13+
-#if defined (HAVE_MEMFD_CREATE) || defined (HAVE_SHM_OPEN) || defined (HAVE_SHM_MKSTEMP)
14+
+#if defined (HAVE_MEMFD_CREATE) || defined (HAVE_SHM_MKSTEMP)
15+
# include <sys/mman.h>
16+
#endif
17+
#include <filecntl.h>
18+
@@ -41,17 +41,7 @@ static int anonunlink (const char *);
19+
# define MFD_NOEXEC_SEAL 0
20+
#endif
21+
22+
-#if defined (HAVE_SHM_OPEN)
23+
-#ifndef O_NOFOLLOW
24+
-# define O_NOFOLLOW 0
25+
-#endif
26+
-
27+
-static int
28+
-anonshmunlink (const char *fn)
29+
-{
30+
- return (shm_unlink (fn));
31+
-}
32+
-
33+
+#if defined (HAVE_SHM_MKSTEMP)
34+
static int
35+
anonshmopen (const char *name, int flags, char **fn)
36+
{
37+
@@ -62,35 +52,14 @@ anonshmopen (const char *name, int flags
38+
if (fn)
39+
*fn = 0;
40+
41+
-#if defined (HAVE_SHM_MKSTEMP)
42+
fname = savestring ("/shm-XXXXXXXXXX");
43+
fd = shm_mkstemp (fname);
44+
if (fd < 0)
45+
- free (fname);
46+
-#endif
47+
-
48+
- if (fd < 0)
49+
- {
50+
- fname = sh_mktmpname (name, flags);
51+
- fd = shm_open (fname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600);
52+
- }
53+
-
54+
- if (fd < 0)
55+
{
56+
free (fname);
57+
return fd;
58+
}
59+
60+
- if (shm_unlink (fname) < 0)
61+
- {
62+
- int o;
63+
- o = errno;
64+
- free (fname);
65+
- close (fd);
66+
- errno = o;
67+
- return -1;
68+
- }
69+
-
70+
if (fn)
71+
*fn = fname;
72+
else
73+
@@ -122,7 +91,7 @@ anonopen (const char *name, int flags, c
74+
/* Heuristic */
75+
flag = (name && *name == '/') ? MT_TEMPLATE : MT_USETMPDIR;
76+
77+
-#if defined (HAVE_SHM_OPEN)
78+
+#if defined (HAVE_SHM_MKSTEMP)
79+
fd = anonshmopen (name, flag, fn);
80+
if (fd >= 0)
81+
return fd; /* anonshmopen sets *FN appropriately */
82+
--- a/patchlevel.h
83+
+++ b/patchlevel.h
84+
@@ -25,6 +25,6 @@
85+
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
86+
looks for to find the patch level (for the sccs version string). */
87+
88+
-#define PATCHLEVEL 1
89+
+#define PATCHLEVEL 2
90+
91+
#endif /* _PATCHLEVEL_H_ */
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 25c37d4804a9dbe0824ba805cc2b7cb94d243682 Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 23 Jul 2025 15:52:32 -0400
4+
Subject: Bash-5.3 patch 3: remove internal quoting that causes failures when
5+
expanding nested array subscripts in an arithmetic context
6+
7+
--- a/patchlevel.h
8+
+++ b/patchlevel.h
9+
@@ -25,6 +25,6 @@
10+
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
11+
looks for to find the patch level (for the sccs version string). */
12+
13+
-#define PATCHLEVEL 2
14+
+#define PATCHLEVEL 3
15+
16+
#endif /* _PATCHLEVEL_H_ */
17+
--- a/subst.c
18+
+++ b/subst.c
19+
@@ -3795,9 +3795,9 @@ pos_params (const char *string, int star
20+
#define EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~')
21+
#endif
22+
23+
-/* We don't perform process substitution in arithmetic expressions, so don't
24+
- bother checking for it. */
25+
-#define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~')
26+
+/* We don't perform process substitution or tilde expansion in arithmetic
27+
+ expressions, so don't bother checking for them. */
28+
+#define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC)
29+
30+
/* If there are any characters in STRING that require full expansion,
31+
then call FUNC to expand STRING; otherwise just perform quote
32+
@@ -12215,6 +12215,14 @@ string_quote_removal (const char *string
33+
*r++ = '\\';
34+
break;
35+
}
36+
+#if defined (ARRAY_VARS)
37+
+ /* The only special characters that matter here are []~, since those
38+
+ are backslash-quoted in expand_array_subscript but not dequoted
39+
+ by the statement following this one. */
40+
+ if ((quoted & Q_ARITH) && (c == LBRACK || c == RBRACK || c == '~'))
41+
+ ; /* placeholder here */
42+
+ else
43+
+#endif
44+
if (((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) && (sh_syntaxtab[c] & CBSDQUOTE) == 0)
45+
*r++ = '\\';
46+
/* FALLTHROUGH */
47+
--- a/tests/quotearray.right
48+
+++ b/tests/quotearray.right
49+
@@ -44,7 +44,7 @@ declare -A assoc=(["\` echo >&2 foo\`"]=
50+
foo
51+
0
52+
0
53+
-./quotearray1.sub: line 68: 0\],b\[1: arithmetic syntax error: invalid arithmetic operator (error token is "\],b\[1")
54+
+./quotearray1.sub: line 68: 0],b[1: arithmetic syntax error: invalid arithmetic operator (error token is "],b[1")
55+
declare -a array
56+
0
57+
0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From edff796a305b09fd991fd8e965d4c83bff91ee39 Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 26 Nov 2025 12:46:21 -0500
4+
Subject: Bash-5.3 patch 4: fix issue with source when read(2) returns fewer
5+
characters than fstat(2) says are available
6+
7+
--- a/builtins/evalfile.c
8+
+++ b/builtins/evalfile.c
9+
@@ -160,8 +160,10 @@ file_error_and_exit:
10+
nr = read (fd, string, file_size);
11+
if (nr >= 0)
12+
string[nr] = '\0';
13+
+#if 0
14+
if (nr != file_size)
15+
nr = -1; /* XXX - didn't get the whole file */
16+
+#endif
17+
}
18+
else
19+
nr = zmapfd (fd, &string, 0);
20+
--- a/patchlevel.h
21+
+++ b/patchlevel.h
22+
@@ -25,6 +25,6 @@
23+
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
24+
looks for to find the patch level (for the sccs version string). */
25+
26+
-#define PATCHLEVEL 3
27+
+#define PATCHLEVEL 4
28+
29+
#endif /* _PATCHLEVEL_H_ */
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From f63f0134b19f303677a4371469158e4618967f63 Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 26 Nov 2025 12:47:49 -0500
4+
Subject: Bash-5.3 patch 5: fix crash when restoring default disposition for
5+
SIGINT in asynchronous subshell
6+
7+
--- a/patchlevel.h
8+
+++ b/patchlevel.h
9+
@@ -25,6 +25,6 @@
10+
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
11+
looks for to find the patch level (for the sccs version string). */
12+
13+
-#define PATCHLEVEL 4
14+
+#define PATCHLEVEL 5
15+
16+
#endif /* _PATCHLEVEL_H_ */
17+
--- a/trap.c
18+
+++ b/trap.c
19+
@@ -964,6 +964,7 @@ restore_default_signal (int sig)
20+
original_signals[sig] = SIG_DFL; /* XXX */
21+
set_signal_handler (sig, SIG_DFL);
22+
change_signal (sig, (char *)DEFAULT_SIG);
23+
+ sigmodes[sig] &= ~SIG_TRAPPED; /* no longer trapped */
24+
return;
25+
}
26+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From c31cd58e6c4d24cec178e9dc6d26a768b4ecbd1d Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 26 Nov 2025 12:49:17 -0500
4+
Subject: Bash-5.3 patch 6: fix issues with range expressions and non-ascii
5+
characters in glob patterns when globasciiranges is enabled
6+
7+
--- a/lib/glob/smatch.c
8+
+++ b/lib/glob/smatch.c
9+
@@ -390,7 +390,7 @@ charcmp_wc (wint_t c1, wint_t c2, int fo
10+
if (c1 == c2)
11+
return 0;
12+
13+
- if (forcecoll == 0 && glob_asciirange && c1 <= UCHAR_MAX && c2 <= UCHAR_MAX)
14+
+ if (forcecoll == 0 && glob_asciirange)
15+
return ((int)(c1 - c2));
16+
17+
s1[0] = c1;
18+
--- a/patchlevel.h
19+
+++ b/patchlevel.h
20+
@@ -25,6 +25,6 @@
21+
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
22+
looks for to find the patch level (for the sccs version string). */
23+
24+
-#define PATCHLEVEL 5
25+
+#define PATCHLEVEL 6
26+
27+
#endif /* _PATCHLEVEL_H_ */
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From a80c21e8b7ff113878ecece1db730fd40bc0ff55 Mon Sep 17 00:00:00 2001
2+
From: Chet Ramey <chet.ramey@case.edu>
3+
Date: Wed, 26 Nov 2025 12:50:54 -0500
4+
Subject: Bash-5.3 patch 7: fix issue where nofork command substitutions can
5+
affect redirections in the calling shell
6+
7+
--- a/patchlevel.h
8+
+++ b/patchlevel.h
9+
@@ -25,6 +25,6 @@
10+
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
11+
looks for to find the patch level (for the sccs version string). */
12+
13+
-#define PATCHLEVEL 6
14+
+#define PATCHLEVEL 7
15+
16+
#endif /* _PATCHLEVEL_H_ */
17+
--- a/subst.c
18+
+++ b/subst.c
19+
@@ -206,6 +206,8 @@ extern int wordexp_only;
20+
extern int singlequote_translations;
21+
extern int extended_quote;
22+
23+
+extern REDIRECT *exec_redirection_undo_list, *redirection_undo_list;
24+
+
25+
#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE)
26+
extern wchar_t *wcsdup (const wchar_t *);
27+
#endif
28+
@@ -7000,6 +7002,11 @@ function_substitute (char *string, int q
29+
add_unwind_protect (uw_restore_pipestatus_array, psa);
30+
}
31+
#endif
32+
+
33+
+ unwind_protect_pointer (redirection_undo_list);
34+
+ redirection_undo_list = NULL;
35+
+ unwind_protect_pointer (exec_redirection_undo_list);
36+
+ exec_redirection_undo_list = NULL;
37+
38+
subst_assign_varlist = 0;
39+

0 commit comments

Comments
 (0)