]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.3-security-errata-20050610.patch
- updated (performance fixes).
[packages/gdb.git] / gdb-6.3-security-errata-20050610.patch
1 http://sourceware.org/ml/gdb-patches/2005-05/threads.html#00637
2 Proposed upstream but never committed upstream.
3
4 2005-06-09  Jeff Johnston  <jjohnstn@redhat.com>
5
6         * gdb.base/gdbinit.exp: New testcase.
7         * gdb.base/gdbinit.sample: Sample .gdbinit for gdbinit.exp.
8
9 2005-06-08  Daniel Jacobowitz  <dan@codesourcery.com>
10             Jeff Johnston  <jjohnstn@redhat.com>
11
12         * Makefile.in (cli-cmds.o): Update.
13         * configure.in: Add check for getuid.
14         * configure: Regenerated.
15         * config.in: Ditto.
16         * main.c (captured_main): Pass -1 to source_command when loading
17         gdbinit files.
18         * cli/cli-cmds.c: Include "gdb_stat.h" and <fcntl.h>.
19         (source_command): Update documentation.  Check permissions if
20         FROM_TTY is -1.
21
22 Index: gdb-7.4.50.20111218/gdb/cli/cli-cmds.c
23 ===================================================================
24 --- gdb-7.4.50.20111218.orig/gdb/cli/cli-cmds.c 2011-12-16 22:17:42.000000000 +0100
25 +++ gdb-7.4.50.20111218/gdb/cli/cli-cmds.c      2011-12-19 00:27:16.572468926 +0100
26 @@ -40,6 +40,7 @@
27  #include "source.h"
28  #include "disasm.h"
29  #include "tracepoint.h"
30 +#include "gdb_stat.h"
31  
32  #include "ui-out.h"
33  
34 @@ -485,7 +486,7 @@ show_script_ext_mode (struct ui_file *fi
35  
36  int
37  find_and_open_script (const char *script_file, int search_path,
38 -                     FILE **streamp, char **full_pathp)
39 +                     FILE **streamp, char **full_pathp, int from_tty)
40  {
41    char *file;
42    int fd;
43 @@ -511,6 +512,32 @@ find_and_open_script (const char *script
44        return 0;
45      }
46  
47 +#ifdef HAVE_GETUID
48 +  if (from_tty == -1)
49 +    {
50 +      struct stat statbuf;
51 +
52 +      if (fstat (fd, &statbuf) < 0)
53 +       {
54 +         int save_errno = errno;
55 +
56 +         close (fd);
57 +         do_cleanups (old_cleanups);
58 +         errno = save_errno;
59 +         return 0;
60 +       }
61 +      if (statbuf.st_uid != getuid () || (statbuf.st_mode & S_IWOTH))
62 +       {
63 +         /* FILE gets freed by do_cleanups (old_cleanups).  */
64 +         warning (_("not using untrusted file \"%s\""), file);
65 +         close (fd);
66 +         do_cleanups (old_cleanups);
67 +         errno = EPERM;
68 +         return 0;
69 +       }
70 +    }
71 +#endif
72 +
73    do_cleanups (old_cleanups);
74  
75    *streamp = fdopen (fd, FOPEN_RT);
76 @@ -572,13 +599,14 @@ source_script_with_search (const char *f
77    if (file == NULL || *file == 0)
78      error (_("source command requires file name of file to source."));
79  
80 -  if (!find_and_open_script (file, search_path, &stream, &full_path))
81 +  if (!find_and_open_script (file, search_path, &stream, &full_path,
82 +                            from_tty))
83      {
84        /* The script wasn't found, or was otherwise inaccessible.
85           If the source command was invoked interactively, throw an
86          error.  Otherwise (e.g. if it was invoked by a script),
87          silently ignore the error.  */
88 -      if (from_tty)
89 +      if (from_tty > 0)
90         perror_with_name (file);
91        else
92         return;
93 Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.exp
94 ===================================================================
95 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
96 +++ gdb-7.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.exp      2011-12-19 00:25:26.079891954 +0100
97 @@ -0,0 +1,91 @@
98 +#   Copyright 2005
99 +#   Free Software Foundation, Inc.
100 +
101 +# This program is free software; you can redistribute it and/or modify
102 +# it under the terms of the GNU General Public License as published by
103 +# the Free Software Foundation; either version 2 of the License, or
104 +# (at your option) any later version.
105 +# 
106 +# This program is distributed in the hope that it will be useful,
107 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
108 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
109 +# GNU General Public License for more details.
110 +# 
111 +# You should have received a copy of the GNU General Public License
112 +# along with this program; if not, write to the Free Software
113 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
114 +
115 +# Please email any bugs, comments, and/or additions to this file to:
116 +# bug-gdb@prep.ai.mit.edu
117 +
118 +# This file was written by Jeff Johnston <jjohnstn@redhat.com>.
119 +
120 +# are we on a target board
121 +if [is_remote target] {
122 +    return
123 +}
124 +
125 +
126 +global verbose
127 +global GDB
128 +global GDBFLAGS
129 +global gdb_prompt
130 +global timeout
131 +global gdb_spawn_id;
132 +
133 +gdb_stop_suppressing_tests;
134 +
135 +verbose "Spawning $GDB -nw"
136 +
137 +if [info exists gdb_spawn_id] {
138 +    return 0;
139 +}
140 +
141 +if ![is_remote host] {
142 +   if { [which $GDB] == 0 } then {
143 +        perror "$GDB does not exist."
144 +        exit 1
145 +    }
146 +}
147 +
148 +set env(HOME) [pwd]
149 +remote_exec build "rm .gdbinit"
150 +remote_exec build "cp ${srcdir}/${subdir}/gdbinit.sample .gdbinit"
151 +remote_exec build "chmod 646 .gdbinit"
152 +
153 +set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
154 +if { $res < 0 || $res == "" } {
155 +    perror "Spawning $GDB failed."
156 +    return 1;
157 +}
158 +gdb_expect 360 {
159 +    -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
160 +        pass "untrusted .gdbinit caught."
161 +    }
162 +    -re "$gdb_prompt $"     {
163 +        fail "untrusted .gdbinit caught."
164 +    }
165 +    timeout {
166 +        fail "(timeout) untrusted .gdbinit caught."
167 +    }
168 +}
169 +
170 +remote_exec build "chmod 644 .gdbinit"
171 +set res [remote_spawn host "$GDB -nw [host_info gdb_opts]"];
172 +if { $res < 0 || $res == "" } {
173 +    perror "Spawning $GDB failed."
174 +    return 1;
175 +}
176 +gdb_expect 360 {
177 +    -re "warning: not using untrusted file.*\.gdbinit.*\[\r\n\]$gdb_prompt $" {
178 +        fail "trusted .gdbinit allowed."
179 +    }
180 +    -re "in gdbinit.*$gdb_prompt $"     {
181 +        pass "trusted .gdbinit allowed."
182 +    }
183 +    timeout {
184 +        fail "(timeout) trusted .gdbinit allowed."
185 +    }
186 +}
187 +
188 +remote_exec build "rm .gdbinit"
189 Index: gdb-7.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.sample
190 ===================================================================
191 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
192 +++ gdb-7.4.50.20111218/gdb/testsuite/gdb.base/gdbinit.sample   2011-12-19 00:25:26.079891954 +0100
193 @@ -0,0 +1 @@
194 +echo "\nin gdbinit"
195 Index: gdb-7.4.50.20111218/gdb/main.c
196 ===================================================================
197 --- gdb-7.4.50.20111218.orig/gdb/main.c 2011-11-05 18:08:30.000000000 +0100
198 +++ gdb-7.4.50.20111218/gdb/main.c      2011-12-19 00:25:26.080891950 +0100
199 @@ -822,7 +822,7 @@ captured_main (void *data)
200       debugging or what directory you are in.  */
201  
202    if (home_gdbinit && !inhibit_gdbinit)
203 -    catch_command_errors (source_script, home_gdbinit, 0, RETURN_MASK_ALL);
204 +    catch_command_errors (source_script, home_gdbinit, -1, RETURN_MASK_ALL);
205  
206    /* Now perform all the actions indicated by the arguments.  */
207    if (cdarg != NULL)
208 @@ -901,7 +901,7 @@ captured_main (void *data)
209    /* Read the .gdbinit file in the current directory, *if* it isn't
210       the same as the $HOME/.gdbinit file (it should exist, also).  */
211    if (local_gdbinit && !inhibit_gdbinit)
212 -    catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL);
213 +    catch_command_errors (source_script, local_gdbinit, -1, RETURN_MASK_ALL);
214  
215    /* Now that all .gdbinit's have been read and all -d options have been
216       processed, we can read any scripts mentioned in SYMARG.
217 Index: gdb-7.4.50.20111218/gdb/python/py-auto-load.c
218 ===================================================================
219 --- gdb-7.4.50.20111218.orig/gdb/python/py-auto-load.c  2011-12-10 23:51:47.000000000 +0100
220 +++ gdb-7.4.50.20111218/gdb/python/py-auto-load.c       2011-12-19 00:25:26.080891950 +0100
221 @@ -284,7 +284,7 @@ source_section_scripts (struct objfile *
222         }
223  
224        opened = find_and_open_script (file, 1 /*search_path*/,
225 -                                    &stream, &full_path);
226 +                                    &stream, &full_path, 1 /* from_tty */);
227  
228        /* If one script isn't found it's not uncommon for more to not be
229          found either.  We don't want to print an error message for each
230 Index: gdb-7.4.50.20111218/gdb/cli/cli-cmds.h
231 ===================================================================
232 --- gdb-7.4.50.20111218.orig/gdb/cli/cli-cmds.h 2011-11-01 15:51:23.000000000 +0100
233 +++ gdb-7.4.50.20111218/gdb/cli/cli-cmds.h      2011-12-19 00:25:26.080891950 +0100
234 @@ -129,7 +129,8 @@ extern void source_script (char *, int);
235  /* Exported to objfiles.c.  */
236  
237  extern int find_and_open_script (const char *file, int search_path,
238 -                                FILE **streamp, char **full_path);
239 +                                FILE **streamp, char **full_path,
240 +                                int from_tty);
241  
242  /* Command tracing state.  */
243  
This page took 0.134479 seconds and 3 git commands to generate.