* [PATCH] Zero supplied stat buffers in functions that pretend to stat
@ 2015-04-13 21:40 Gary Benson
2015-04-13 21:54 ` Pedro Alves
0 siblings, 1 reply; 4+ messages in thread
From: Gary Benson @ 2015-04-13 21:40 UTC (permalink / raw)
To: gdb-patches
Hi all,
GDB has five places where it pretends to stat for bfd_openr_iovec.
Four of these only set the incoming buffer's st_size, leaving the
other fields unchanged, which is to say very likely populated with
random values from the stack. remote_bfd_iovec_stat was fixed in
0a93529c56714b1da3d7106d3e0300764f8bb81c; this commit fixes the
other four.
Built and and regtested on RHEL6.6 x86_64.
Ok to commit?
Cheers,
Gary
gdb/ChangeLog:
* jit.c (mem_bfd_iovec_stat): Zero supplied buffer.
* minidebug.c (lzma_stat): Likewise.
* solib-spu.c (spu_bfd_iovec_stat): Likewise.
* spu-linux-nat.c (spu_bfd_iovec_stat): Likewise.
---
gdb/ChangeLog | 7 +++++++
gdb/jit.c | 1 +
gdb/minidebug.c | 1 +
gdb/solib-spu.c | 1 +
gdb/spu-linux-nat.c | 1 +
5 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/gdb/jit.c b/gdb/jit.c
index e872c8f..f977ea6 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -126,6 +126,7 @@ mem_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb)
{
struct target_buffer *buffer = (struct target_buffer*) stream;
+ memset (sb, 0, sizeof (struct stat));
sb->st_size = buffer->size;
return 0;
}
diff --git a/gdb/minidebug.c b/gdb/minidebug.c
index cc20914..98c2187 100644
--- a/gdb/minidebug.c
+++ b/gdb/minidebug.c
@@ -241,6 +241,7 @@ lzma_stat (struct bfd *abfd,
{
struct gdb_lzma_stream *lstream = stream;
+ memset (sb, 0, sizeof (struct stat));
sb->st_size = lzma_index_uncompressed_size (lstream->index);
return 0;
}
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index 250cf21..44fbf91 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -313,6 +313,7 @@ spu_bfd_iovec_stat (bfd *abfd, void *stream, struct stat *sb)
table to find the extent of the last section but that seems
pointless when the size is needed only for checks of other
parsed values in dbxread.c. */
+ memset (sb, 0, sizeof (struct stat));
sb->st_size = INT_MAX;
return 0;
}
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index b0942a9..a043f53 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -313,6 +313,7 @@ spu_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb)
table to find the extent of the last section but that seems
pointless when the size is needed only for checks of other
parsed values in dbxread.c. */
+ memset (sb, 0, sizeof (struct stat));
sb->st_size = INT_MAX;
return 0;
}
--
1.7.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Zero supplied stat buffers in functions that pretend to stat
2015-04-13 21:40 [PATCH] Zero supplied stat buffers in functions that pretend to stat Gary Benson
@ 2015-04-13 21:54 ` Pedro Alves
2015-04-14 8:04 ` Gary Benson
0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2015-04-13 21:54 UTC (permalink / raw)
To: Gary Benson, gdb-patches
On 04/13/2015 10:40 PM, Gary Benson wrote:
> Hi all,
>
> GDB has five places where it pretends to stat for bfd_openr_iovec.
> Four of these only set the incoming buffer's st_size, leaving the
> other fields unchanged, which is to say very likely populated with
> random values from the stack. remote_bfd_iovec_stat was fixed in
> 0a93529c56714b1da3d7106d3e0300764f8bb81c; this commit fixes the
> other four.
>
> Built and and regtested on RHEL6.6 x86_64.
>
> Ok to commit?
Eh, how apropos for the bfd cache discussion.
OK, thanks.
--
Pedro Alves
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Zero supplied stat buffers in functions that pretend to stat
2015-04-13 21:54 ` Pedro Alves
@ 2015-04-14 8:04 ` Gary Benson
2015-04-14 11:37 ` Gary Benson
0 siblings, 1 reply; 4+ messages in thread
From: Gary Benson @ 2015-04-14 8:04 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Pedro Alves wrote:
> On 04/13/2015 10:40 PM, Gary Benson wrote:
> > GDB has five places where it pretends to stat for bfd_openr_iovec.
> > Four of these only set the incoming buffer's st_size, leaving the
> > other fields unchanged, which is to say very likely populated with
> > random values from the stack. remote_bfd_iovec_stat was fixed in
> > 0a93529c56714b1da3d7106d3e0300764f8bb81c; this commit fixes the
> > other four.
> >
> > Built and and regtested on RHEL6.6 x86_64.
> >
> > Ok to commit?
>
> Eh, how apropos for the bfd cache discussion.
Yeah, I've been meaning to reply to that :)
> OK, thanks.
Will push it later.
Cheers,
Gary
--
http://gbenson.net/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Zero supplied stat buffers in functions that pretend to stat
2015-04-14 8:04 ` Gary Benson
@ 2015-04-14 11:37 ` Gary Benson
0 siblings, 0 replies; 4+ messages in thread
From: Gary Benson @ 2015-04-14 11:37 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Gary Benson wrote:
> Pedro Alves wrote:
> > On 04/13/2015 10:40 PM, Gary Benson wrote:
> > > GDB has five places where it pretends to stat for bfd_openr_iovec.
> > > Four of these only set the incoming buffer's st_size, leaving the
> > > other fields unchanged, which is to say very likely populated with
> > > random values from the stack. remote_bfd_iovec_stat was fixed in
> > > 0a93529c56714b1da3d7106d3e0300764f8bb81c; this commit fixes the
> > > other four.
> > >
> > > Built and and regtested on RHEL6.6 x86_64.
> > >
> > > Ok to commit?
> >
> > Eh, how apropos for the bfd cache discussion.
>
> Yeah, I've been meaning to reply to that :)
>
> > OK, thanks.
>
> Will push it later.
Pushed.
Cheers,
Gary
--
http://gbenson.net/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-14 11:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 21:40 [PATCH] Zero supplied stat buffers in functions that pretend to stat Gary Benson
2015-04-13 21:54 ` Pedro Alves
2015-04-14 8:04 ` Gary Benson
2015-04-14 11:37 ` Gary Benson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox