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

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