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

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