]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
Bash-5.0 patch 8: fix history offset when HISTSIZE == 0 that can lead to crashes
authorChet Ramey <chet.ramey@case.edu>
Wed, 14 Aug 2019 18:57:48 +0000 (14:57 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 14 Aug 2019 18:57:48 +0000 (14:57 -0400)
bashhist.c
patchlevel.h

index 7912cce311871da3766979ffe60178a4d03ce06d..d2155dce1e16da46ea54f2f61dd147c922307abd 100644 (file)
@@ -560,15 +560,18 @@ pre_process_line (line, print_changes, addit)
      add that line to the history if ADDIT is non-zero. */
   if (!history_expansion_inhibited && history_expansion && history_expansion_p (line))
     {
+      int old_len;
+
       /* If we are expanding the second or later line of a multi-line
         command, decrease history_length so references to history expansions
         in these lines refer to the previous history entry and not the
         current command. */
+      old_len = history_length;
       if (history_length > 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
         history_length--;
       expanded = history_expand (line, &history_value);
       if (history_length >= 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
-        history_length++;
+        history_length = old_len;
 
       if (expanded)
        {
index deb9c5b74a5b0029aa4d05c25dd32d4ae378000b..16c8740455079ee12e9773dd1eb8860313fbdffd 100644 (file)
@@ -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 7
+#define PATCHLEVEL 8
 
 #endif /* _PATCHLEVEL_H_ */