diff options
author | Giuseppe Scrivano <gscrivano@gnu.org> | 2016-02-01 09:58:52 +0100 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2016-03-06 12:13:32 -0800 |
commit | 17e2698bcbee30a6cc282d61ad6242a64ba9c7cf (patch) | |
tree | 38a58fae31dad830db363ea90dfd211a31c193b1 /tests | |
parent | 3d8affcc9dd85da0de0121e95a6f932d68feb5fa (diff) | |
download | diffutils-17e2698bcbee30a6cc282d61ad6242a64ba9c7cf.tar.gz |
diff: --color: fix an infinite recursion bug
* src/diff.h (presume_output_tty): New extern variable.
* src/diff.c (PRESUME_OUTPUT_TTY_OPTION): New enum.
(group_format_option): Add '-presume-output-tty'.
(main): Handle PRESUME_OUTPUT_TTY_OPTION.
* src/util.c: New variable `presume_output_tty'.
(check_color_output): Handle presume_output_tty.
(set_color_context): Call process_signals only when color_context is
not RESET_CONTEXT.
* tests/colors: Check that diff doesn't crash when interrupted
in the middle of a color sequence.
Reported by Gisle Vanem in http://debbugs.gnu.org/22067
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/colors | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/colors b/tests/colors index facfd8d..881c1b8 100755 --- a/tests/colors +++ b/tests/colors @@ -116,4 +116,13 @@ test $? = 1 || fail=1 gen_exp_u > exp || framework_failure_ compare exp out || fail=1 +# Before the fix in http://debbugs.gnu.org/22067, +# this test would trigger an infinite loop bug. +mkfifo fifo +printf '%*s-a' 1000000 > a +printf '%*s-b' 1000000 > b +head -c 10 < fifo > /dev/null & +diff --color=always ---presume-output-tty a b > fifo +test $? = 141 || fail=1 + Exit $fail |