1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/gdb/6.7.1/100-security-errata-20050610.patch Fri Oct 02 22:10:38 2009 +0200
1.3 @@ -0,0 +1,205 @@
1.4 +Original patch from gentoo: gentoo/src/patchsets/gdb/6.7.1/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.7.1.orig/gdb/cli/cli-cmds.c gdb-6.7.1/gdb/cli/cli-cmds.c
1.26 +--- gdb-6.7.1.orig/gdb/cli/cli-cmds.c 2007-08-23 20:08:47.000000000 +0200
1.27 ++++ gdb-6.7.1/gdb/cli/cli-cmds.c 2008-06-17 23:27:44.000000000 +0200
1.28 +@@ -36,6 +36,7 @@
1.29 + #include "objfiles.h"
1.30 + #include "source.h"
1.31 + #include "disasm.h"
1.32 ++#include "gdb_stat.h"
1.33 +
1.34 + #include "ui-out.h"
1.35 +
1.36 +@@ -459,12 +460,31 @@
1.37 +
1.38 + if (fd == -1)
1.39 + {
1.40 +- if (from_tty)
1.41 ++ if (from_tty > 0)
1.42 + perror_with_name (file);
1.43 + else
1.44 + return;
1.45 + }
1.46 +
1.47 ++#ifdef HAVE_GETUID
1.48 ++ if (from_tty == -1)
1.49 ++ {
1.50 ++ struct stat statbuf;
1.51 ++ if (fstat (fd, &statbuf) < 0)
1.52 ++ {
1.53 ++ perror_with_name (file);
1.54 ++ close (fd);
1.55 ++ return;
1.56 ++ }
1.57 ++ if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH))
1.58 ++ {
1.59 ++ warning (_("not using untrusted file \"%s\""), file);
1.60 ++ close (fd);
1.61 ++ return;
1.62 ++ }
1.63 ++ }
1.64 ++#endif
1.65 ++
1.66 + stream = fdopen (fd, FOPEN_RT);
1.67 + script_from_file (stream, file);
1.68 +
1.69 +diff -durN gdb-6.7.1.orig/gdb/main.c gdb-6.7.1/gdb/main.c
1.70 +--- gdb-6.7.1.orig/gdb/main.c 2007-08-23 20:08:36.000000000 +0200
1.71 ++++ gdb-6.7.1/gdb/main.c 2008-06-17 23:27:44.000000000 +0200
1.72 +@@ -688,7 +688,7 @@
1.73 +
1.74 + if (!inhibit_gdbinit)
1.75 + {
1.76 +- catch_command_errors (source_script, homeinit, 0, RETURN_MASK_ALL);
1.77 ++ catch_command_errors (source_script, homeinit, -1, RETURN_MASK_ALL);
1.78 + }
1.79 +
1.80 + /* Do stats; no need to do them elsewhere since we'll only
1.81 +@@ -766,7 +766,7 @@
1.82 + || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat)))
1.83 + if (!inhibit_gdbinit)
1.84 + {
1.85 +- catch_command_errors (source_script, gdbinit, 0, RETURN_MASK_ALL);
1.86 ++ catch_command_errors (source_script, gdbinit, -1, RETURN_MASK_ALL);
1.87 + }
1.88 +
1.89 + for (i = 0; i < ncmd; i++)
1.90 +diff -durN gdb-6.7.1.orig/gdb/Makefile.in gdb-6.7.1/gdb/Makefile.in
1.91 +--- gdb-6.7.1.orig/gdb/Makefile.in 2008-06-17 23:27:44.000000000 +0200
1.92 ++++ gdb-6.7.1/gdb/Makefile.in 2008-06-17 23:27:44.000000000 +0200
1.93 +@@ -2885,7 +2885,7 @@
1.94 + $(expression_h) $(frame_h) $(value_h) $(language_h) $(filenames_h) \
1.95 + $(objfiles_h) $(source_h) $(disasm_h) $(ui_out_h) $(top_h) \
1.96 + $(cli_decode_h) $(cli_script_h) $(cli_setshow_h) $(cli_cmds_h) \
1.97 +- $(tui_h)
1.98 ++ $(tui_h) $(gdb_stat_h)
1.99 + $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-cmds.c
1.100 + cli-decode.o: $(srcdir)/cli/cli-decode.c $(defs_h) $(symtab_h) \
1.101 + $(gdb_regex_h) $(gdb_string_h) $(completer_h) $(ui_out_h) \
1.102 +diff -durN gdb-6.7.1.orig/gdb/testsuite/gdb.base/gdbinit.exp gdb-6.7.1/gdb/testsuite/gdb.base/gdbinit.exp
1.103 +--- gdb-6.7.1.orig/gdb/testsuite/gdb.base/gdbinit.exp 1970-01-01 01:00:00.000000000 +0100
1.104 ++++ gdb-6.7.1/gdb/testsuite/gdb.base/gdbinit.exp 2008-06-17 23:27:44.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.7.1.orig/gdb/testsuite/gdb.base/gdbinit.sample gdb-6.7.1/gdb/testsuite/gdb.base/gdbinit.sample
1.205 +--- gdb-6.7.1.orig/gdb/testsuite/gdb.base/gdbinit.sample 1970-01-01 01:00:00.000000000 +0100
1.206 ++++ gdb-6.7.1/gdb/testsuite/gdb.base/gdbinit.sample 2008-06-17 23:27:44.000000000 +0200
1.207 +@@ -0,0 +1 @@
1.208 ++echo "\nin gdbinit"