bash: Update to patch level 3

Message ID 20250807152247.1954170-1-adolf.belka@ipfire.org
State Staged
Commit 0fb4546ddf85187a423ca56a7b012f5074d9c089
Headers
Series bash: Update to patch level 3 |

Commit Message

Adolf Belka 7 Aug 2025, 3:22 p.m. UTC
- Update from patch level 0 to 3
- Update of rootfile not required
- Changelog
    Patch 3
	Bash leaves internal quoting in place when expanding array subscripts
	 that appear inside array subscripts in an arithmetic context, causing
	 expansion failures.
    Patch 2
	There are too many differences in the various implementations of shm_open(2)
	 to rely on it for bash's use.
    Patch 1
	In posix mode, `wait -n' with pid arguments does not restrict the set of
	 processes it considers to those arguments.

Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
 lfs/bash                    |   2 +-
 src/patches/bash/bash53-001 |  48 ++++++++++++++
 src/patches/bash/bash53-002 | 122 ++++++++++++++++++++++++++++++++++++
 src/patches/bash/bash53-003 |  82 ++++++++++++++++++++++++
 4 files changed, 253 insertions(+), 1 deletion(-)
 create mode 100644 src/patches/bash/bash53-001
 create mode 100644 src/patches/bash/bash53-002
 create mode 100644 src/patches/bash/bash53-003
  

Patch

diff --git a/lfs/bash b/lfs/bash
index a09326198..1bc7b52f6 100644
--- a/lfs/bash
+++ b/lfs/bash
@@ -25,7 +25,7 @@ 
 include Config
 
 VER        = 5.3
-PATCHVER   = 0
+PATCHVER   = 3
 
 THISAPP    = bash-$(VER)
 DL_FILE    = $(THISAPP).tar.gz
diff --git a/src/patches/bash/bash53-001 b/src/patches/bash/bash53-001
new file mode 100644
index 000000000..17c1d89db
--- /dev/null
+++ b/src/patches/bash/bash53-001
@@ -0,0 +1,48 @@ 
+			     BASH PATCH REPORT
+			     =================
+
+Bash-Release:	5.3
+Patch-ID:	bash53-001
+
+Bug-Reported-by:	John Sidles <jasidles@gmail.com>
+Bug-Reference-ID:	<CAHOxHhRKa86FtRpsq-FBVciAxZ9kbo5PvfQBovBDXDFySbxj7A@mail.gmail.com>
+Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-bash/2025-07/msg00035.html
+
+Bug-Description:
+
+In posix mode, `wait -n' with pid arguments does not restrict the set of
+processes it considers to those arguments.
+
+Patch (apply with `patch -p0'):
+
+*** ../bash-5.3/jobs.c	Fri Mar  7 18:48:44 2025
+--- jobs.c	Mon Jul 14 10:25:13 2025
+***************
+*** 3539,3543 ****
+       one in bgpids. We can do this in posix mode because we'll remove any
+       one we find from the table, preserving existing semantics. */
+!   if (posixly_correct && (t = bgp_findone ()))
+      {
+        pid = t->pid;
+--- 3539,3543 ----
+       one in bgpids. We can do this in posix mode because we'll remove any
+       one we find from the table, preserving existing semantics. */
+!   if (posixly_correct && (flags & JWAIT_WAITING) == 0 && (t = bgp_findone ()))
+      {
+        pid = t->pid;
+
+*** ../bash-5.3/patchlevel.h	2020-06-22 14:51:03.000000000 -0400
+--- patchlevel.h	2020-10-01 11:01:28.000000000 -0400
+***************
+*** 26,30 ****
+     looks for to find the patch level (for the sccs version string). */
+  
+! #define PATCHLEVEL 0
+  
+  #endif /* _PATCHLEVEL_H_ */
+--- 26,30 ----
+     looks for to find the patch level (for the sccs version string). */
+  
+! #define PATCHLEVEL 1
+  
+  #endif /* _PATCHLEVEL_H_ */
diff --git a/src/patches/bash/bash53-002 b/src/patches/bash/bash53-002
new file mode 100644
index 000000000..cddc90e87
--- /dev/null
+++ b/src/patches/bash/bash53-002
@@ -0,0 +1,122 @@ 
+			     BASH PATCH REPORT
+			     =================
+
+Bash-Release:	5.3
+Patch-ID:	bash53-002
+
+Bug-Reported-by:	
+Bug-Reference-ID:
+Bug-Reference-URL:	https://savannah.gnu.org/bugs/?67326
+
+Bug-Description:
+
+There are too many differences in the various implementations of shm_open(2)
+to rely on it for bash's use.
+
+Patch (apply with `patch -p0'):
+
+*** ../bash-5.3-patched/lib/sh/anonfile.c	Tue Jul  9 11:41:57 2024
+--- lib/sh/anonfile.c	Thu Jul 17 11:03:23 2025
+***************
+*** 26,30 ****
+  #include <bashtypes.h>
+  
+! #if defined (HAVE_MEMFD_CREATE) || defined (HAVE_SHM_OPEN) || defined (HAVE_SHM_MKSTEMP)
+  #  include <sys/mman.h>
+  #endif
+--- 26,30 ----
+  #include <bashtypes.h>
+  
+! #if defined (HAVE_MEMFD_CREATE) || defined (HAVE_SHM_MKSTEMP)
+  #  include <sys/mman.h>
+  #endif
+***************
+*** 42,57 ****
+  #endif
+  
+! #if defined (HAVE_SHM_OPEN)
+! #ifndef O_NOFOLLOW
+! #  define O_NOFOLLOW 0
+! #endif
+! 
+  static int
+- anonshmunlink (const char *fn)
+- {
+-   return (shm_unlink (fn));
+- }
+- 
+- static int
+  anonshmopen (const char *name, int flags, char **fn)
+  {
+--- 42,47 ----
+  #endif
+  
+! #if defined (HAVE_SHM_MKSTEMP)
+  static int
+  anonshmopen (const char *name, int flags, char **fn)
+  {
+***************
+*** 63,95 ****
+      *fn = 0;
+  
+- #if defined (HAVE_SHM_MKSTEMP)
+    fname = savestring ("/shm-XXXXXXXXXX");
+    fd = shm_mkstemp (fname);
+    if (fd < 0)
+-     free (fname);
+- #endif
+- 
+-   if (fd < 0)
+      {
+-       fname = sh_mktmpname (name, flags);
+-       fd = shm_open (fname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600);
+-     }
+- 
+-   if (fd < 0)
+-     {
+        free (fname);
+        return fd;
+      }
+  
+-   if (shm_unlink (fname) < 0)
+-     {
+-       int o;
+-       o = errno;
+-       free (fname);
+-       close (fd);
+-       errno = o;
+-       return -1;
+-     }
+- 
+    if (fn)
+      *fn = fname;
+--- 53,64 ----
+***************
+*** 123,127 ****
+    flag = (name && *name == '/') ? MT_TEMPLATE : MT_USETMPDIR;
+  
+! #if defined (HAVE_SHM_OPEN)
+    fd = anonshmopen (name, flag, fn);
+    if (fd >= 0)
+--- 92,96 ----
+    flag = (name && *name == '/') ? MT_TEMPLATE : MT_USETMPDIR;
+  
+! #if defined (HAVE_SHM_MKSTEMP)
+    fd = anonshmopen (name, flag, fn);
+    if (fd >= 0)
+
+*** ../bash-5.3/patchlevel.h	2020-06-22 14:51:03.000000000 -0400
+--- patchlevel.h	2020-10-01 11:01:28.000000000 -0400
+***************
+*** 26,30 ****
+     looks for to find the patch level (for the sccs version string). */
+  
+! #define PATCHLEVEL 1
+  
+  #endif /* _PATCHLEVEL_H_ */
+--- 26,30 ----
+     looks for to find the patch level (for the sccs version string). */
+  
+! #define PATCHLEVEL 2
+  
+  #endif /* _PATCHLEVEL_H_ */
diff --git a/src/patches/bash/bash53-003 b/src/patches/bash/bash53-003
new file mode 100644
index 000000000..0fc6b42e0
--- /dev/null
+++ b/src/patches/bash/bash53-003
@@ -0,0 +1,82 @@ 
+			     BASH PATCH REPORT
+			     =================
+
+Bash-Release:	5.3
+Patch-ID:	bash53-003
+
+Bug-Reported-by:	Isabella Bosia <izaberina@gmail.com>
+Bug-Reference-ID:	<CAAZkfoJhQ1BJ7BGk3-ObctvCJJrW3rp_tWQXT=9rY7kGDvz4uw@mail.gmail.com>
+Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-bash/2025-06/msg00173.html
+
+Bug-Description:
+
+Bash leaves internal quoting in place when expanding array subscripts
+that appear inside array subscripts in an arithmetic context, causing
+expansion failures.
+
+Patch (apply with `patch -p0'):
+
+*** ../bash-5.3-patched/subst.c	Sun May 18 15:00:13 2025
+--- subst.c	Fri Jul 11 09:48:44 2025
+***************
+*** 3796,3802 ****
+  #endif
+  
+! /* We don't perform process substitution in arithmetic expressions, so don't
+!    bother checking for it. */
+! #define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~')
+  
+  /* If there are any characters in STRING that require full expansion,
+--- 3796,3802 ----
+  #endif
+  
+! /* We don't perform process substitution or tilde expansion in arithmetic
+!    expressions, so don't bother checking for them. */
+! #define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC)
+  
+  /* If there are any characters in STRING that require full expansion,
+***************
+*** 12216,12219 ****
+--- 12216,12227 ----
+  	      break;
+  	    }
++ #if defined (ARRAY_VARS)
++ 	  /* The only special characters that matter here are []~, since those
++ 	     are backslash-quoted in expand_array_subscript but not dequoted
++ 	     by the statement following this one. */
++ 	  if ((quoted & Q_ARITH) && (c == LBRACK || c == RBRACK || c == '~'))
++ 	    ;		/* placeholder here */
++ 	  else
++ #endif
+  	  if (((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) && (sh_syntaxtab[c] & CBSDQUOTE) == 0)
+  	    *r++ = '\\';
+*** ../bash-5.3/tests/quotearray.right	Thu Nov 10 10:39:56 2022
+--- tests/quotearray.right	Thu Jul 10 15:40:27 2025
+***************
+*** 45,49 ****
+  0
+  0
+! ./quotearray1.sub: line 68: 0\],b\[1: arithmetic syntax error: invalid arithmetic operator (error token is "\],b\[1")
+  declare -a array
+  0
+--- 45,49 ----
+  0
+  0
+! ./quotearray1.sub: line 68: 0],b[1: arithmetic syntax error: invalid arithmetic operator (error token is "],b[1")
+  declare -a array
+  0
+*** ../bash-5.3/patchlevel.h	2020-06-22 14:51:03.000000000 -0400
+--- patchlevel.h	2020-10-01 11:01:28.000000000 -0400
+***************
+*** 26,30 ****
+     looks for to find the patch level (for the sccs version string). */
+  
+! #define PATCHLEVEL 2
+  
+  #endif /* _PATCHLEVEL_H_ */
+--- 26,30 ----
+     looks for to find the patch level (for the sccs version string). */
+  
+! #define PATCHLEVEL 3
+  
+  #endif /* _PATCHLEVEL_H_ */