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

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