141-upstream-bash43-041.patch (2182B)
1 BASH PATCH REPORT 2 ================= 3 4 Bash-Release: 4.3 5 Patch-ID: bash43-041 6 7 Bug-Reported-by: Hanno Böck <hanno@hboeck.de> 8 Bug-Reference-ID: <20150623131106.6f111da9@pc1>, <20150707004640.0e61d2f9@pc1> 9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2015-06/msg00089.html, 10 http://lists.gnu.org/archive/html/bug-bash/2015-07/msg00018.html 11 12 Bug-Description: 13 14 There are several out-of-bounds read errors that occur when completing command 15 lines where assignment statements appear before the command name. The first 16 two appear only when programmable completion is enabled; the last one only 17 happens when listing possible completions. 18 19 Patch (apply with `patch -p0'): 20 21 --- a/bashline.c 22 +++ b/bashline.c 23 @@ -1468,10 +1468,23 @@ attempt_shell_completion (text, start, e 24 25 os = start; 26 n = 0; 27 + was_assignment = 0; 28 s = find_cmd_start (os); 29 e = find_cmd_end (end); 30 do 31 { 32 + /* Don't read past the end of rl_line_buffer */ 33 + if (s > rl_end) 34 + { 35 + s1 = s = e1; 36 + break; 37 + } 38 + /* Or past point if point is within an assignment statement */ 39 + else if (was_assignment && s > rl_point) 40 + { 41 + s1 = s = e1; 42 + break; 43 + } 44 /* Skip over assignment statements preceding a command name. If we 45 don't find a command name at all, we can perform command name 46 completion. If we find a partial command name, we should perform 47 --- a/lib/readline/complete.c 48 +++ b/lib/readline/complete.c 49 @@ -689,6 +689,8 @@ printable_part (pathname) 50 51 if (temp == 0 || *temp == '\0') 52 return (pathname); 53 + else if (temp[1] == 0 && temp == pathname) 54 + return (pathname); 55 /* If the basename is NULL, we might have a pathname like '/usr/src/'. 56 Look for a previous slash and, if one is found, return the portion 57 following that slash. If there's no previous slash, just return the 58 --- a/patchlevel.h 59 +++ b/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 40 65 +#define PATCHLEVEL 41 66 67 #endif /* _PATCHLEVEL_H_ */