7bc793b
From 01323582f773ef4d08fa26a90e9a21285a8405f5 Mon Sep 17 00:00:00 2001
7bc793b
From: Chet Ramey <chet.ramey@case.edu>
7bc793b
Date: Wed, 14 Aug 2019 14:57:48 -0400
7bc793b
Subject: [PATCH] Bash-5.0 patch 8: fix history offset when HISTSIZE == 0 that
7bc793b
 can lead to crashes
7bc793b
7bc793b
---
7bc793b
 bashhist.c   | 5 ++++-
7bc793b
 patchlevel.h | 2 +-
7bc793b
 2 files changed, 5 insertions(+), 2 deletions(-)
7bc793b
7bc793b
diff --git a/bashhist.c b/bashhist.c
7bc793b
index 7912cce3..d2155dce 100644
7bc793b
--- a/bashhist.c
7bc793b
+++ b/bashhist.c
7bc793b
@@ -560,15 +560,18 @@ pre_process_line (line, print_changes, addit)
7bc793b
      add that line to the history if ADDIT is non-zero. */
7bc793b
   if (!history_expansion_inhibited && history_expansion && history_expansion_p (line))
7bc793b
     {
7bc793b
+      int old_len;
7bc793b
+
7bc793b
       /* If we are expanding the second or later line of a multi-line
7bc793b
 	 command, decrease history_length so references to history expansions
7bc793b
 	 in these lines refer to the previous history entry and not the
7bc793b
 	 current command. */
7bc793b
+      old_len = history_length;
7bc793b
       if (history_length > 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
7bc793b
         history_length--;
7bc793b
       expanded = history_expand (line, &history_value);
7bc793b
       if (history_length >= 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
7bc793b
-        history_length++;
7bc793b
+        history_length = old_len;
7bc793b
 
7bc793b
       if (expanded)
7bc793b
 	{
7bc793b
diff --git a/patchlevel.h b/patchlevel.h
7bc793b
index deb9c5b7..16c87404 100644
7bc793b
--- a/patchlevel.h
7bc793b
+++ b/patchlevel.h
7bc793b
@@ -25,6 +25,6 @@
7bc793b
    regexp `^#define[ 	]*PATCHLEVEL', since that's what support/mkversion.sh
7bc793b
    looks for to find the patch level (for the sccs version string). */
7bc793b
 
7bc793b
-#define PATCHLEVEL 7
7bc793b
+#define PATCHLEVEL 8
7bc793b
 
7bc793b
 #endif /* _PATCHLEVEL_H_ */
7bc793b
-- 
7bc793b
2.21.0
7bc793b