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

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