Skip to content

Commit 0132358

Browse files
author
Chet Ramey
committed
Bash-5.0 patch 8: fix history offset when HISTSIZE == 0 that can lead to crashes
1 parent 3ba6974 commit 0132358

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

bashhist.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,18 @@ pre_process_line (line, print_changes, addit)
560560
add that line to the history if ADDIT is non-zero. */
561561
if (!history_expansion_inhibited && history_expansion && history_expansion_p (line))
562562
{
563+
int old_len;
564+
563565
/* If we are expanding the second or later line of a multi-line
564566
command, decrease history_length so references to history expansions
565567
in these lines refer to the previous history entry and not the
566568
current command. */
569+
old_len = history_length;
567570
if (history_length > 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
568571
history_length--;
569572
expanded = history_expand (line, &history_value);
570573
if (history_length >= 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
571-
history_length++;
574+
history_length = old_len;
572575

573576
if (expanded)
574577
{

patchlevel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
2626
looks for to find the patch level (for the sccs version string). */
2727

28-
#define PATCHLEVEL 7
28+
#define PATCHLEVEL 8
2929

3030
#endif /* _PATCHLEVEL_H_ */

0 commit comments

Comments
 (0)