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

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