7 Bug-Reported-by: Matthias Klose <doko@debian.org>
8 Bug-Reference-ID: <53346FC8.6090005@debian.org>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00171.html
13 There is a problem with unsigned sign extension when attempting to reallocate
14 the input line when it is fewer than 3 characters long and there has been a
15 history expansion. The sign extension causes the shell to not reallocate the
16 line, which results in a segmentation fault when it writes past the end.
18 Patch (apply with `patch -p0'):
22 @@ -2424,7 +2424,7 @@ shell_getc (remove_quoted_newline)
23 not already end in an EOF character. */
24 if (shell_input_line_terminator != EOF)
26 - if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
27 + if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
28 shell_input_line = (char *)xrealloc (shell_input_line,
29 1 + (shell_input_line_size += 2));
33 @@ -4736,7 +4736,7 @@ shell_getc (remove_quoted_newline)
34 not already end in an EOF character. */
35 if (shell_input_line_terminator != EOF)
37 - if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
38 + if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
39 shell_input_line = (char *)xrealloc (shell_input_line,
40 1 + (shell_input_line_size += 2));
45 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
46 looks for to find the patch level (for the sccs version string). */
51 #endif /* _PATCHLEVEL_H_ */