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

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