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

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