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

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