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

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