1.1 --- a/patches/gdb/6.8/110-security-errata-20050610.patch Fri Sep 09 15:48:59 2011 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,205 +0,0 @@
1.4 -Original patch from gentoo: gentoo/src/patchsets/gdb/6.8/35_all_gdb-6.3-security-errata-20050610.patch
1.5 --= BEGIN original header =-
1.6 -2005-06-09 Jeff Johnston <jjohnstn@redhat.com>
1.7 -
1.8 - * gdb.base/gdbinit.exp: New testcase.
1.9 - * gdb.base/gdbinit.sample: Sample .gdbinit for gdbinit.exp.
1.10 -
1.11 -2005-06-08 Daniel Jacobowitz <dan@codesourcery.com>
1.12 - Jeff Johnston <jjohnstn@redhat.com>
1.13 -
1.14 - * Makefile.in (cli-cmds.o): Update.
1.15 - * configure.in: Add check for getuid.
1.16 - * configure: Regenerated.
1.17 - * config.in: Ditto.
1.18 - * main.c (captured_main): Pass -1 to source_command when loading
1.19 - gdbinit files.
1.20 - * cli/cli-cmds.c: Include "gdb_stat.h" and <fcntl.h>.
1.21 - (source_command): Update documentation. Check permissions if
1.22 - FROM_TTY is -1.
1.23 -
1.24 --= END original header =-
1.25 -diff -durN gdb-6.8.orig/gdb/Makefile.in gdb-6.8/gdb/Makefile.in
1.26 ---- gdb-6.8.orig/gdb/Makefile.in 2008-03-17 13:15:08.000000000 +0100
1.27 -+++ gdb-6.8/gdb/Makefile.in 2008-06-17 16:07:33.000000000 +0200
1.28 -@@ -3004,7 +3004,7 @@
1.29 - $(expression_h) $(frame_h) $(value_h) $(language_h) $(filenames_h) \
1.30 - $(objfiles_h) $(source_h) $(disasm_h) $(ui_out_h) $(top_h) \
1.31 - $(cli_decode_h) $(cli_script_h) $(cli_setshow_h) $(cli_cmds_h) \
1.32 -- $(tui_h)
1.33 -+ $(tui_h) $(gdb_stat_h)
1.34 - $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-cmds.c
1.35 - cli-decode.o: $(srcdir)/cli/cli-decode.c $(defs_h) $(symtab_h) \
1.36 - $(gdb_regex_h) $(gdb_string_h) $(completer_h) $(ui_out_h) \
1.37 -diff -durN gdb-6.8.orig/gdb/cli/cli-cmds.c gdb-6.8/gdb/cli/cli-cmds.c
1.38 ---- gdb-6.8.orig/gdb/cli/cli-cmds.c 2008-01-01 23:53:14.000000000 +0100
1.39 -+++ gdb-6.8/gdb/cli/cli-cmds.c 2008-06-17 16:07:33.000000000 +0200
1.40 -@@ -36,6 +36,7 @@
1.41 - #include "objfiles.h"
1.42 - #include "source.h"
1.43 - #include "disasm.h"
1.44 -+#include "gdb_stat.h"
1.45 -
1.46 - #include "ui-out.h"
1.47 -
1.48 -@@ -459,12 +460,31 @@
1.49 -
1.50 - if (fd == -1)
1.51 - {
1.52 -- if (from_tty)
1.53 -+ if (from_tty > 0)
1.54 - perror_with_name (file);
1.55 - else
1.56 - return;
1.57 - }
1.58 -
1.59 -+#ifdef HAVE_GETUID
1.60 -+ if (from_tty == -1)
1.61 -+ {
1.62 -+ struct stat statbuf;
1.63 -+ if (fstat (fd, &statbuf) < 0)
1.64 -+ {
1.65 -+ perror_with_name (file);
1.66 -+ close (fd);
1.67 -+ return;
1.68 -+ }
1.69 -+ if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH))
1.70 -+ {
1.71 -+ warning (_("not using untrusted file \"%s\""), file);
1.72 -+ close (fd);
1.73 -+ return;
1.74 -+ }
1.75 -+ }
1.76 -+#endif
1.77 -+
1.78 - stream = fdopen (fd, FOPEN_RT);
1.79 - script_from_file (stream, file);
1.80 -
1.81 -diff -durN gdb-6.8.orig/gdb/main.c gdb-6.8/gdb/main.c
1.82 ---- gdb-6.8.orig/gdb/main.c 2008-01-05 17:49:53.000000000 +0100
1.83 -+++ gdb-6.8/gdb/main.c 2008-06-17 16:07:33.000000000 +0200
1.84 -@@ -690,7 +690,7 @@
1.85 -
1.86 - if (!inhibit_gdbinit)
1.87 - {
1.88 -- catch_command_errors (source_script, homeinit, 0, RETURN_MASK_ALL);
1.89 -+ catch_command_errors (source_script, homeinit, -1, RETURN_MASK_ALL);
1.90 - }
1.91 -
1.92 - /* Do stats; no need to do them elsewhere since we'll only
1.93 -@@ -778,7 +778,7 @@
1.94 - || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat)))
1.95 - if (!inhibit_gdbinit)
1.96 - {
1.97 -- catch_command_errors (source_script, gdbinit, 0, RETURN_MASK_ALL);
1.98 -+ catch_command_errors (source_script, gdbinit, -1, RETURN_MASK_ALL);
1.99 - }
1.100 -
1.101 - for (i = 0; i < ncmd; i++)
1.102 -diff -durN gdb-6.8.orig/gdb/testsuite/gdb.base/gdbinit.exp gdb-6.8/gdb/testsuite/gdb.base/gdbinit.exp
1.103 ---- gdb-6.8.orig/gdb/testsuite/gdb.base/gdbinit.exp 1970-01-01 01:00:00.000000000 +0100
1.104 -+++ gdb-6.8/gdb/testsuite/gdb.base/gdbinit.exp 2008-06-17 16:07:33.000000000 +0200
1.105 -@@ -0,0 +1,98 @@
1.106 -+# Copyright 2005
1.107 -+# Free Software Foundation, Inc.
1.108 -+
1.109 -+# This program is free software; you can redistribute it and/or modify
1.110 -+# it under the terms of the GNU General Public License as published by
1.111 -+# the Free Software Foundation; either version 2 of the License, or
1.112 -+# (at your option) any later version.
1.113 -+#
1.114 -+# This program is distributed in the hope that it will be useful,
1.115 -+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1.116 -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.117 -+# GNU General Public License for more details.
1.118 -+#
1.119 -+# You should have received a copy of the GNU General Public License
1.120 -+# along with this program; if not, write to the Free Software
1.121 -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1.122 -+
1.123 -+# Please email any bugs, comments, and/or additions to this file to:
1.124 -+# bug-gdb@prep.ai.mit.edu
1.125 -+
1.126 -+# This file was written by Jeff Johnston <jjohnstn@redhat.com>.
1.127 -+
1.128 -+if $tracelevel then {
1.129 -+ strace $tracelevel
1.130 -+}
1.131 -+
1.132 -+set prms_id 0
1.133 -+set bug_id 0
1.134 -+
1.135 -+# are we on a target board
1.136 -+if [is_remote target] {
1.137 -+ return
1.138 -+}
1.139 -+
1.140 -+
1.141 -+global verbose
1.142 -+global GDB
1.143 -+global GDBFLAGS
1.144 -+global gdb_prompt
1.145 -+global timeout
1.146 -+global gdb_spawn_id;
1.147 -+
1.148 -+gdb_stop_suppressing_tests;
1.149 -+
1.150 -+verbose "Spawning $GDB -nw"
1.151 -+
1.152 -+if [info exists gdb_spawn_id] {
1.153 -+ return 0;
1.154 -+}
1.155 -+
1.156 -+if ![is_remote host] {
1.157 -+ if { [which $GDB] == 0 } then {
1.158 -+ perror "$GDB does not exist."
1.159 -+ exit 1
1.160 -+ }
1.161 -+}
1.162 -+
1.163 -+set env(HOME) [pwd]
1.164 -+remote_exec build "rm .gdbinit"
1.165 -+remote_exec build "cp ${srcdir}/${subdir}/gdbinit.sample .gdbinit"
1.166 -+remote_exec build "chmod 646 .gdbinit"
1.167 -+
1.168 -+set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
1.169 -+if { $res < 0 || $res == "" } {
1.170 -+ perror "Spawning $GDB failed."
1.171 -+ return 1;
1.172 -+}
1.173 -+gdb_expect 360 {
1.174 -+ -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
1.175 -+ pass "untrusted .gdbinit caught."
1.176 -+ }
1.177 -+ -re "$gdb_prompt $" {
1.178 -+ fail "untrusted .gdbinit caught."
1.179 -+ }
1.180 -+ timeout {
1.181 -+ fail "(timeout) untrusted .gdbinit caught."
1.182 -+ }
1.183 -+}
1.184 -+
1.185 -+remote_exec build "chmod 644 .gdbinit"
1.186 -+set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
1.187 -+if { $res < 0 || $res == "" } {
1.188 -+ perror "Spawning $GDB failed."
1.189 -+ return 1;
1.190 -+}
1.191 -+gdb_expect 360 {
1.192 -+ -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
1.193 -+ fail "trusted .gdbinit allowed."
1.194 -+ }
1.195 -+ -re "in gdbinit.*$gdb_prompt $" {
1.196 -+ pass "trusted .gdbinit allowed."
1.197 -+ }
1.198 -+ timeout {
1.199 -+ fail "(timeout) trusted .gdbinit allowed."
1.200 -+ }
1.201 -+}
1.202 -+
1.203 -+remote_exec build "rm .gdbinit"
1.204 -diff -durN gdb-6.8.orig/gdb/testsuite/gdb.base/gdbinit.sample gdb-6.8/gdb/testsuite/gdb.base/gdbinit.sample
1.205 ---- gdb-6.8.orig/gdb/testsuite/gdb.base/gdbinit.sample 1970-01-01 01:00:00.000000000 +0100
1.206 -+++ gdb-6.8/gdb/testsuite/gdb.base/gdbinit.sample 2008-06-17 16:07:33.000000000 +0200
1.207 -@@ -0,0 +1 @@
1.208 -+echo "\nin gdbinit"