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