1 From https://ftp.gnu.org/gnu/bash/bash-4.4-patches/bash44-009
3 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
11 Bug-Reported-by: Hong Cho <hong.cho@citrix.com>
12 Bug-Reference-ID: <c30b5fe62b2543af8297e47ca487c29c@SJCPEX02CL02.citrite.net>
13 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2016-12/msg00043.html
17 There is a race condition in add_history() that can be triggered by a fatal
18 signal arriving between the time the history length is updated and the time
19 the history list update is completed. A later attempt to reference an
20 invalid history entry can cause a crash.
22 Patch (apply with `patch -p0'):
24 *** bash-4.4-patched/lib/readline/history.c 2016-11-11 13:42:49.000000000 -0500
25 --- b/lib/readline/history.c 2016-12-05 10:37:51.000000000 -0500
33 if (history_stifled && (history_length == history_max_entries))
36 /* Copy the rest of the entries, moving down one slot. Copy includes
39 - for (i = 0; i < history_length; i++)
40 - the_history[i] = the_history[i + 1];
42 memmove (the_history, the_history + 1, history_length * sizeof (HIST_ENTRY *));
48 /* Copy the rest of the entries, moving down one slot. Copy includes
50 memmove (the_history, the_history + 1, history_length * sizeof (HIST_ENTRY *));
52 + new_length = history_length;
57 history_size = DEFAULT_HISTORY_INITIAL_SIZE;
58 the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *));
63 history_size = DEFAULT_HISTORY_INITIAL_SIZE;
64 the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *));
70 xrealloc (the_history, history_size * sizeof (HIST_ENTRY *));
76 xrealloc (the_history, history_size * sizeof (HIST_ENTRY *));
78 ! new_length = history_length + 1;
83 temp = alloc_history_entry ((char *)string, hist_inittime ());
85 ! the_history[history_length] = (HIST_ENTRY *)NULL;
86 ! the_history[history_length - 1] = temp;
90 temp = alloc_history_entry ((char *)string, hist_inittime ());
92 ! the_history[new_length] = (HIST_ENTRY *)NULL;
93 ! the_history[new_length - 1] = temp;
94 ! history_length = new_length;
97 *** bash-4.4/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
98 --- b/patchlevel.h 2016-10-01 11:01:28.000000000 -0400
101 looks for to find the patch level (for the sccs version string). */
103 ! #define PATCHLEVEL 8
105 #endif /* _PATCHLEVEL_H_ */
107 looks for to find the patch level (for the sccs version string). */
109 ! #define PATCHLEVEL 9
111 #endif /* _PATCHLEVEL_H_ */