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

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