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

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