Zero supplied stat buffers in functions that pretend to stat
authorGary Benson <gbenson@redhat.com>
Tue, 14 Apr 2015 11:35:30 +0000 (12:35 +0100)
committerGary Benson <gbenson@redhat.com>
Tue, 14 Apr 2015 11:35:30 +0000 (12:35 +0100)
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.

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
gdb/jit.c
gdb/minidebug.c
gdb/solib-spu.c
gdb/spu-linux-nat.c

index 9a027f327688a057c4921a08744ee404cc474f43..acb408b7e053773433f1c172a35494b1a4be4ef9 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-14  Gary Benson <gbenson@redhat.com>
+
+       * 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.
+
 2015-04-13  Stan Shebs  <stanshebs@google.com>
 
        * MAINTAINERS: Update my email address.
index e872c8fe25f012b64dea44ddc5ed457edcf4b1d0..f977ea66f5ac3a739ab88120f286f3cb66367e97 100644 (file)
--- 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;
 }
index cc20914b787a2dcfb6f9a5ecb0dd0bde8e9cc265..98c2187f7ffc134e0780e126b92565f9efc85360 100644 (file)
@@ -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;
 }
index 250cf212eda119ca33300c7f6db4f0ec3a297562..44fbf91506c4eb0758f1e6c4e75f54ada09d4429 100644 (file)
@@ -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;
 }
index b0942a9c5bb2d1f405280c175be6395e1dd59f89..a043f53d3777c6375bdc9dda615cf7e81eb5dbf0 100644 (file)
@@ -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;
 }
This page took 0.033605 seconds and 4 git commands to generate.