Blame SOURCES/gdb-6.5-readline-long-line-crash-test.patch

ab2726
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
ab2726
From: Fedora GDB patches <invalid@email.com>
ab2726
Date: Fri, 27 Oct 2017 21:07:50 +0200
ab2726
Subject: gdb-6.5-readline-long-line-crash-test.patch
ab2726
ab2726
;; Fix readline segfault on excessively long hand-typed lines.
ab2726
;;=fedoratest
ab2726
ab2726
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
ab2726
ab2726
diff --git a/gdb/testsuite/gdb.base/readline-overflow.exp b/gdb/testsuite/gdb.base/readline-overflow.exp
ab2726
new file mode 100644
ab2726
--- /dev/null
ab2726
+++ b/gdb/testsuite/gdb.base/readline-overflow.exp
ab2726
@@ -0,0 +1,96 @@
ab2726
+# Copyright 2006 Free Software Foundation, Inc.
ab2726
+
ab2726
+# This program is free software; you can redistribute it and/or modify
ab2726
+# it under the terms of the GNU General Public License as published by
ab2726
+# the Free Software Foundation; either version 2 of the License, or
ab2726
+# (at your option) any later version.
ab2726
+#
ab2726
+# This program is distributed in the hope that it will be useful,
ab2726
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
ab2726
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ab2726
+# GNU General Public License for more details.
ab2726
+#
ab2726
+# You should have received a copy of the GNU General Public License
ab2726
+# along with this program; if not, write to the Free Software
ab2726
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ab2726
+
ab2726
+# Please email any bugs, comments, and/or additions to this file to:
ab2726
+# bug-gdb@prep.ai.mit.edu
ab2726
+
ab2726
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>
ab2726
+
ab2726
+# This file is part of the gdb testsuite.
ab2726
+
ab2726
+#
ab2726
+# Tests for readline buffer overflow.
ab2726
+#
ab2726
+
ab2726
+if $tracelevel {
ab2726
+  strace $tracelevel
ab2726
+}
ab2726
+
ab2726
+global env
ab2726
+
ab2726
+save_vars { env(GDBHISTFILE) env(HISTSIZE) TERM timeout } {
ab2726
+    # The arrow key test relies on the standard VT100 bindings, so
ab2726
+    # make sure that an appropriate terminal is selected.  The same
ab2726
+    # bug doesn't show up if we use ^P / ^N instead.
ab2726
+    setenv TERM vt100
ab2726
+
ab2726
+    set timeout 600
ab2726
+
ab2726
+    set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
ab2726
+    set env(HISTSIZE) "10"
ab2726
+
ab2726
+    gdb_exit
ab2726
+    gdb_start
ab2726
+    gdb_reinitialize_dir $srcdir/$subdir
ab2726
+
ab2726
+
ab2726
+    set width 11
ab2726
+    gdb_test "set width $width" \
ab2726
+	"" \
ab2726
+	"Setting width to $width."
ab2726
+    #gdb_test "set height 1" \
ab2726
+	#         "" \
ab2726
+	#         "Setting height to 1."
ab2726
+    send_gdb "run X"
ab2726
+    set i 0
ab2726
+    # It crashes using `set width 7' on `set total 3560'.
ab2726
+    # Sometimes it corrupts screen on `set width 7'.
ab2726
+    # Bugreport used `set total 130001':
ab2726
+    # 	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
ab2726
+    # Check also `timeout' above.
ab2726
+    set total 4200
ab2726
+    gdb_expect {
ab2726
+	-re X {
ab2726
+	    incr i
ab2726
+	    if {$i <= $total} {
ab2726
+		send_gdb "X"
ab2726
+		exp_continue
ab2726
+	    }
ab2726
+	}
ab2726
+	-re "\[ \b\r\n\]" {
ab2726
+	    exp_continue
ab2726
+	}
ab2726
+	eof {
ab2726
+	    fail "gdb sending total $total characters"
ab2726
+	    note "Failed after sending $i characters, reason: EOF"
ab2726
+	    gdb_clear_suppressed
ab2726
+	}
ab2726
+	timeout {
ab2726
+	    fail "gdb sending total $total characters"
ab2726
+	    note "Failed after sending $i characters (timeout $timeout), reason: TIMEOUT"
ab2726
+	    gdb_clear_suppressed
ab2726
+	}
ab2726
+	default {
ab2726
+	    fail "gdb sending total $total characters"
ab2726
+	    note "Failed after sending $i characters, reason: 0=\[$expect_out(0,string)\] buffer=\[$expect_out(buffer)\]"
ab2726
+	    gdb_clear_suppressed
ab2726
+	}
ab2726
+    }
ab2726
+    send_gdb "\r"
ab2726
+    gdb_test "" \
ab2726
+	"No executable file specified..*" \
ab2726
+	"All the characters transferred"
ab2726
+}