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

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