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

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