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

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