chiark / gitweb /
Disable all exported shell functions
[bash.git] / debian / patches / bash42-009.diff
1 # DP: bash-4.2 upstream patch 009
2
3                              BASH PATCH REPORT
4                              =================
5
6 Bash-Release:   4.2
7 Patch-ID:       bash42-009
8
9 Bug-Reported-by:        <piuma@piumalab.org>
10 Bug-Reference-ID:       <4DAAC0DB.7060606@piumalab.org>
11 Bug-Reference-URL:      http://lists.gnu.org/archive/html/bug-bash/2011-04/msg00075.html
12
13 Bug-Description:
14
15 Under certain circumstances, running `fc -l' two times in succession with a
16 relative history offset at the end of the history will result in an incorrect
17 calculation of the last history entry and a seg fault.
18
19 Patch (apply with `patch -p0'):
20
21 --- a/bash/builtins/fc.def
22 +++ b/bash/builtins/fc.def
23 @@ -304,7 +304,7 @@
24    last_hist = i - rh - hist_last_line_added;
25  
26    /* XXX */
27 -  if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
28 +  if (i == last_hist && hlist[last_hist] == 0)
29      while (last_hist >= 0 && hlist[last_hist] == 0)
30        last_hist--;
31    if (last_hist < 0)
32 @@ -475,7 +475,7 @@
33       HIST_ENTRY **hlist;
34  {
35    int sign, n, clen, rh;
36 -  register int i, j;
37 +  register int i, j, last_hist;
38    register char *s;
39  
40    sign = 1;
41 @@ -495,7 +495,15 @@
42       has been enabled (interactive or not) should use it in the last_hist
43       calculation as if it were on. */
44    rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
45 -  i -= rh + hist_last_line_added;
46 +  last_hist = i - rh - hist_last_line_added;
47 +
48 +  if (i == last_hist && hlist[last_hist] == 0)
49 +    while (last_hist >= 0 && hlist[last_hist] == 0)
50 +      last_hist--;
51 +  if (last_hist < 0)
52 +    return (-1);
53 +
54 +  i = last_hist;
55  
56    /* No specification defaults to most recent command. */
57    if (command == NULL)
58 --- a/bash/patchlevel.h
59 +++ b/bash/patchlevel.h
60 @@ -25,6 +25,6 @@
61     regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
62     looks for to find the patch level (for the sccs version string). */
63  
64 -#define PATCHLEVEL 8
65 +#define PATCHLEVEL 9
66  
67  #endif /* _PATCHLEVEL_H_ */