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

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