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