Magellan Linux

Annotation of /trunk/gdb/patches/gdb-6.6-security-errata-20050610.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (hide annotations) (download)
Tue May 8 20:06:05 2007 UTC (17 years, 1 month ago) by niro
File size: 6392 byte(s)
-import

1 niro 144 2005-06-09 Jeff Johnston <jjohnstn@redhat.com>
2    
3     * gdb.base/gdbinit.exp: New testcase.
4     * gdb.base/gdbinit.sample: Sample .gdbinit for gdbinit.exp.
5    
6     2005-06-08 Daniel Jacobowitz <dan@codesourcery.com>
7     Jeff Johnston <jjohnstn@redhat.com>
8    
9     * Makefile.in (cli-cmds.o): Update.
10     * configure.in: Add check for getuid.
11     * configure: Regenerated.
12     * config.in: Ditto.
13     * main.c (captured_main): Pass -1 to source_command when loading
14     gdbinit files.
15     * cli/cli-cmds.c: Include "gdb_stat.h" and <fcntl.h>.
16     (source_command): Update documentation. Check permissions if
17     FROM_TTY is -1.
18    
19     Index: gdb-6.6/gdb/cli/cli-cmds.c
20     ===================================================================
21     --- gdb-6.6.orig/gdb/cli/cli-cmds.c
22     +++ gdb-6.6/gdb/cli/cli-cmds.c
23     @@ -38,6 +38,7 @@
24     #include "objfiles.h"
25     #include "source.h"
26     #include "disasm.h"
27     +#include "gdb_stat.h"
28    
29     #include "ui-out.h"
30    
31     @@ -461,12 +462,31 @@ source_script (char *file, int from_tty)
32    
33     if (fd == -1)
34     {
35     - if (from_tty)
36     + if (from_tty > 0)
37     perror_with_name (file);
38     else
39     return;
40     }
41    
42     +#ifdef HAVE_GETUID
43     + if (from_tty == -1)
44     + {
45     + struct stat statbuf;
46     + if (fstat (fd, &statbuf) < 0)
47     + {
48     + perror_with_name (file);
49     + close (fd);
50     + return;
51     + }
52     + if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH))
53     + {
54     + warning (_("not using untrusted file \"%s\""), file);
55     + close (fd);
56     + return;
57     + }
58     + }
59     +#endif
60     +
61     stream = fdopen (fd, FOPEN_RT);
62     script_from_file (stream, file);
63    
64     Index: gdb-6.6/gdb/testsuite/gdb.base/gdbinit.exp
65     ===================================================================
66     --- /dev/null
67     +++ gdb-6.6/gdb/testsuite/gdb.base/gdbinit.exp
68     @@ -0,0 +1,98 @@
69     +# Copyright 2005
70     +# Free Software Foundation, Inc.
71     +
72     +# This program is free software; you can redistribute it and/or modify
73     +# it under the terms of the GNU General Public License as published by
74     +# the Free Software Foundation; either version 2 of the License, or
75     +# (at your option) any later version.
76     +#
77     +# This program is distributed in the hope that it will be useful,
78     +# but WITHOUT ANY WARRANTY; without even the implied warranty of
79     +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80     +# GNU General Public License for more details.
81     +#
82     +# You should have received a copy of the GNU General Public License
83     +# along with this program; if not, write to the Free Software
84     +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
85     +
86     +# Please email any bugs, comments, and/or additions to this file to:
87     +# bug-gdb@prep.ai.mit.edu
88     +
89     +# This file was written by Jeff Johnston <jjohnstn@redhat.com>.
90     +
91     +if $tracelevel then {
92     + strace $tracelevel
93     +}
94     +
95     +set prms_id 0
96     +set bug_id 0
97     +
98     +# are we on a target board
99     +if [is_remote target] {
100     + return
101     +}
102     +
103     +
104     +global verbose
105     +global GDB
106     +global GDBFLAGS
107     +global gdb_prompt
108     +global timeout
109     +global gdb_spawn_id;
110     +
111     +gdb_stop_suppressing_tests;
112     +
113     +verbose "Spawning $GDB -nw"
114     +
115     +if [info exists gdb_spawn_id] {
116     + return 0;
117     +}
118     +
119     +if ![is_remote host] {
120     + if { [which $GDB] == 0 } then {
121     + perror "$GDB does not exist."
122     + exit 1
123     + }
124     +}
125     +
126     +set env(HOME) [pwd]
127     +remote_exec build "rm .gdbinit"
128     +remote_exec build "cp ${srcdir}/${subdir}/gdbinit.sample .gdbinit"
129     +remote_exec build "chmod 646 .gdbinit"
130     +
131     +set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
132     +if { $res < 0 || $res == "" } {
133     + perror "Spawning $GDB failed."
134     + return 1;
135     +}
136     +gdb_expect 360 {
137     + -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
138     + pass "untrusted .gdbinit caught."
139     + }
140     + -re "$gdb_prompt $" {
141     + fail "untrusted .gdbinit caught."
142     + }
143     + timeout {
144     + fail "(timeout) untrusted .gdbinit caught."
145     + }
146     +}
147     +
148     +remote_exec build "chmod 644 .gdbinit"
149     +set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
150     +if { $res < 0 || $res == "" } {
151     + perror "Spawning $GDB failed."
152     + return 1;
153     +}
154     +gdb_expect 360 {
155     + -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
156     + fail "trusted .gdbinit allowed."
157     + }
158     + -re "in gdbinit.*$gdb_prompt $" {
159     + pass "trusted .gdbinit allowed."
160     + }
161     + timeout {
162     + fail "(timeout) trusted .gdbinit allowed."
163     + }
164     +}
165     +
166     +remote_exec build "rm .gdbinit"
167     Index: gdb-6.6/gdb/testsuite/gdb.base/gdbinit.sample
168     ===================================================================
169     --- /dev/null
170     +++ gdb-6.6/gdb/testsuite/gdb.base/gdbinit.sample
171     @@ -0,0 +1 @@
172     +echo "\nin gdbinit"
173     Index: gdb-6.6/gdb/main.c
174     ===================================================================
175     --- gdb-6.6.orig/gdb/main.c
176     +++ gdb-6.6/gdb/main.c
177     @@ -644,7 +644,7 @@ extern int gdbtk_test (char *);
178    
179     if (!inhibit_gdbinit)
180     {
181     - catch_command_errors (source_script, homeinit, 0, RETURN_MASK_ALL);
182     + catch_command_errors (source_script, homeinit, -1, RETURN_MASK_ALL);
183     }
184    
185     /* Do stats; no need to do them elsewhere since we'll only
186     @@ -722,7 +722,7 @@ extern int gdbtk_test (char *);
187     || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat)))
188     if (!inhibit_gdbinit)
189     {
190     - catch_command_errors (source_script, gdbinit, 0, RETURN_MASK_ALL);
191     + catch_command_errors (source_script, gdbinit, -1, RETURN_MASK_ALL);
192     }
193    
194     for (i = 0; i < ncmd; i++)
195     Index: gdb-6.6/gdb/Makefile.in
196     ===================================================================
197     --- gdb-6.6.orig/gdb/Makefile.in
198     +++ gdb-6.6/gdb/Makefile.in
199     @@ -2927,7 +2927,7 @@ cli-cmds.o: $(srcdir)/cli/cli-cmds.c $(d
200     $(expression_h) $(frame_h) $(value_h) $(language_h) $(filenames_h) \
201     $(objfiles_h) $(source_h) $(disasm_h) $(ui_out_h) $(top_h) \
202     $(cli_decode_h) $(cli_script_h) $(cli_setshow_h) $(cli_cmds_h) \
203     - $(tui_h)
204     + $(tui_h) $(gdb_stat_h)
205     $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-cmds.c
206     cli-decode.o: $(srcdir)/cli/cli-decode.c $(defs_h) $(symtab_h) \
207     $(gdb_regex_h) $(gdb_string_h) $(completer_h) $(ui_out_h) \