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

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