Update to bash-4.4 patchlevel 23

Resolves: #1585510
This commit is contained in:
Siteshwar Vashisht 2018-06-12 13:52:41 +02:00
parent f379fd1f6a
commit 00951800e5
5 changed files with 285 additions and 3 deletions

136
bash-4.4-patch-20.patch Normal file
View File

@ -0,0 +1,136 @@
From 354efb96f1e4574f458e994163bbe31c76769573 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Fri, 1 Jun 2018 10:19:56 -0400
Subject: [PATCH] saved background process status hash table loop fixes
---
jobs.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++-------------
patchlevel.h | 2 +-
2 files changed, 50 insertions(+), 14 deletions(-)
diff --git a/jobs.c b/jobs.c
index fc966036..2684632d 100644
--- a/jobs.c
+++ b/jobs.c
@@ -812,8 +812,22 @@ bgp_add (pid, status)
ps_index_t *bucket, psi;
struct pidstat *ps;
- bucket = pshash_getbucket (pid);
- psi = bgp_getindex ();
+ /* bucket == existing chain of pids hashing to same value
+ psi = where were going to put this pid/status */
+
+ bucket = pshash_getbucket (pid); /* index into pidstat_table */
+ psi = bgp_getindex (); /* bgpids.head, index into storage */
+
+ /* XXX - what if psi == *bucket? */
+ if (psi == *bucket)
+ {
+#ifdef DEBUG
+ internal_warning ("hashed pid %d (pid %d) collides with bgpids.head, skipping", psi, pid);
+#endif
+ bgpids.storage[psi].pid = NO_PID; /* make sure */
+ psi = bgp_getindex (); /* skip to next one */
+ }
+
ps = &bgpids.storage[psi];
ps->pid = pid;
@@ -841,32 +855,47 @@ pshash_delindex (psi)
ps_index_t psi;
{
struct pidstat *ps;
+ ps_index_t *bucket;
ps = &bgpids.storage[psi];
if (ps->pid == NO_PID)
return;
- if (ps->bucket_next != NO_PID)
+ if (ps->bucket_next != NO_PIDSTAT)
bgpids.storage[ps->bucket_next].bucket_prev = ps->bucket_prev;
- if (ps->bucket_prev != NO_PID)
+ if (ps->bucket_prev != NO_PIDSTAT)
bgpids.storage[ps->bucket_prev].bucket_next = ps->bucket_next;
else
- *(pshash_getbucket (ps->pid)) = ps->bucket_next;
+ {
+ bucket = pshash_getbucket (ps->pid);
+ *bucket = ps->bucket_next; /* deleting chain head in hash table */
+ }
+
+ /* clear out this cell, just in case */
+ ps->pid = NO_PID;
+ ps->bucket_next = ps->bucket_prev = NO_PIDSTAT;
}
static int
bgp_delete (pid)
pid_t pid;
{
- ps_index_t psi;
+ ps_index_t psi, orig_psi;
if (bgpids.storage == 0 || bgpids.nalloc == 0 || bgpids.npid == 0)
return 0;
/* Search chain using hash to find bucket in pidstat_table */
- for (psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
- if (bgpids.storage[psi].pid == pid)
- break;
+ for (orig_psi = psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
+ {
+ if (bgpids.storage[psi].pid == pid)
+ break;
+ if (orig_psi == bgpids.storage[psi].bucket_next) /* catch reported bug */
+ {
+ internal_warning ("bgp_delete: LOOP: psi (%d) == storage[psi].bucket_next", psi);
+ return 0;
+ }
+ }
if (psi == NO_PIDSTAT)
return 0; /* not found */
@@ -904,15 +933,22 @@ static int
bgp_search (pid)
pid_t pid;
{
- ps_index_t psi;
+ ps_index_t psi, orig_psi;
if (bgpids.storage == 0 || bgpids.nalloc == 0 || bgpids.npid == 0)
return -1;
/* Search chain using hash to find bucket in pidstat_table */
- for (psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
- if (bgpids.storage[psi].pid == pid)
- return (bgpids.storage[psi].status);
+ for (orig_psi = psi = *(pshash_getbucket (pid)); psi != NO_PIDSTAT; psi = bgpids.storage[psi].bucket_next)
+ {
+ if (bgpids.storage[psi].pid == pid)
+ return (bgpids.storage[psi].status);
+ if (orig_psi == bgpids.storage[psi].bucket_next) /* catch reported bug */
+ {
+ internal_warning ("bgp_search: LOOP: psi (%d) == storage[psi].bucket_next", psi);
+ return -1;
+ }
+ }
return -1;
}
diff --git a/patchlevel.h b/patchlevel.h
index a711c495..4a65dc0f 100644
--- 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 19
+#define PATCHLEVEL 20
#endif /* _PATCHLEVEL_H_ */
--
2.14.4

48
bash-4.4-patch-21.patch Normal file
View File

@ -0,0 +1,48 @@
From 36f89ff1d8b761c815d8993e9833e6357a57fc6b Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Fri, 1 Jun 2018 10:20:32 -0400
Subject: [PATCH] SIGINT trap handler SIGINT loop fix
---
jobs.c | 12 +++++++++++-
patchlevel.h | 2 +-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/jobs.c b/jobs.c
index 2684632d..5ee21e10 100644
--- a/jobs.c
+++ b/jobs.c
@@ -2689,7 +2689,17 @@ wait_for (pid)
wait_sigint_received = child_caught_sigint = 0;
if (job_control == 0 || (subshell_environment&SUBSHELL_COMSUB))
{
- old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
+ SigHandler *temp_sigint_handler;
+
+ temp_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
+ if (temp_sigint_handler == wait_sigint_handler)
+ {
+#if defined (DEBUG)
+ internal_warning ("wait_for: recursively setting old_sigint_handler to wait_sigint_handler: running_trap = %d", running_trap);
+#endif
+ }
+ else
+ old_sigint_handler = temp_sigint_handler;
waiting_for_child = 0;
if (old_sigint_handler == SIG_IGN)
set_signal_handler (SIGINT, old_sigint_handler);
diff --git a/patchlevel.h b/patchlevel.h
index 4a65dc0f..d87b0ba7 100644
--- 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 20
+#define PATCHLEVEL 21
#endif /* _PATCHLEVEL_H_ */
--
2.14.4

47
bash-4.4-patch-22.patch Normal file
View File

@ -0,0 +1,47 @@
From 34dbca51a5fb5938db2e69ebb3318bbb182c2902 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Fri, 1 Jun 2018 10:22:00 -0400
Subject: [PATCH] readline multi-key command re-read input fix
---
lib/readline/readline.c | 4 ++--
patchlevel.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index e51df4f0..a05b35e5 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -1057,7 +1057,7 @@ _rl_subseq_result (r, map, key, got_subseq)
/* We probably shadowed a keymap, so keep going. */
r = _rl_dispatch (ANYOTHERKEY, m);
}
- else if (r && map[ANYOTHERKEY].function)
+ else if (r < 0 && map[ANYOTHERKEY].function)
{
/* We didn't match (r is probably -1), so return something to
tell the caller that it should try ANYOTHERKEY for an
@@ -1069,7 +1069,7 @@ _rl_subseq_result (r, map, key, got_subseq)
_rl_dispatching_keymap = map;
return -2;
}
- else if (r && got_subseq)
+ else if (r < 0 && got_subseq) /* XXX */
{
/* OK, back up the chain. */
if (RL_ISSTATE (RL_STATE_MACROINPUT))
diff --git a/patchlevel.h b/patchlevel.h
index d87b0ba7..9be226c3 100644
--- 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 21
+#define PATCHLEVEL 22
#endif /* _PATCHLEVEL_H_ */
--
2.14.4

47
bash-4.4-patch-23.patch Normal file
View File

@ -0,0 +1,47 @@
From 64447609994bfddeef1061948022c074093e9a9f Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Fri, 1 Jun 2018 10:22:36 -0400
Subject: [PATCH] fix for SIGINT in sourced script
---
builtins/trap.def | 4 ++++
patchlevel.h | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/builtins/trap.def b/builtins/trap.def
index 57d9b522..d43b0ef6 100644
--- a/builtins/trap.def
+++ b/builtins/trap.def
@@ -98,6 +98,7 @@ static int display_traps __P((WORD_LIST *));
#define IGNORE 2 /* Ignore this signal. */
extern int posixly_correct, subshell_environment;
+extern int sourcelevel, running_trap;
int
trap_builtin (list)
@@ -212,6 +213,9 @@ trap_builtin (list)
was SIG_IGN? */
if (interactive)
set_signal_handler (SIGINT, sigint_sighandler);
+ /* special cases for interactive == 0 */
+ else if (interactive_shell && (sourcelevel||running_trap))
+ set_signal_handler (SIGINT, sigint_sighandler);
else
set_signal_handler (SIGINT, termsig_sighandler);
break;
diff --git a/patchlevel.h b/patchlevel.h
index 9be226c3..2060b58f 100644
--- 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 22
+#define PATCHLEVEL 23
#endif /* _PATCHLEVEL_H_ */
--
2.14.4

View File

@ -1,13 +1,13 @@
#% define beta_tag rc2
%global _hardened_build 1
%define patchleveltag .19
%define patchleveltag .23
%define baseversion 4.4
%bcond_without tests
Version: %{baseversion}%{patchleveltag}
Name: bash
Summary: The GNU Bourne Again shell
Release: 2%{?dist}
Release: 1%{?dist}
License: GPLv3+
Url: https://www.gnu.org/software/bash
Source0: https://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz
@ -21,7 +21,7 @@ Source3: dot-bash_logout
# Official upstream patches
# Patches are converted to apply with '-p1'
%{lua:for i=1,19 do print(string.format("Patch%u: bash-4.4-patch-%u.patch\n", i, i)) end}
%{lua:for i=1,23 do print(string.format("Patch%u: bash-4.4-patch-%u.patch\n", i, i)) end}
# Other patches
Patch101: bash-2.02-security.patch
@ -316,6 +316,10 @@ end
%{_libdir}/pkgconfig/%{name}.pc
%changelog
* Tue Jun 12 2018 Siteshwar Vashisht <svashisht@redhat.com> - 4.4.23-1
- Update to bash-4.4 patchlevel 23
Resolves: #1585510
* Thu Mar 15 2018 Siteshwar Vashisht <svashisht@redhat.com> - 4.4.19-2
- Fix handling case statement in command subsitution
Resolves: #1556867