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

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