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

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