diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2020-01-15 18:48:13 +0000 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2020-01-30 13:06:24 +0000 |
commit | 87b2920fc54826c2a0015ab3a19b7b873d208653 (patch) | |
tree | b2318a012a0603c2be95530d2a30ce2ca57877aa /bfd | |
parent | bd434cc4d94ec3d2f9fc1e7c00c27b074f962bc1 (diff) | |
download | gdb-87b2920fc54826c2a0015ab3a19b7b873d208653.zip gdb-87b2920fc54826c2a0015ab3a19b7b873d208653.tar.gz gdb-87b2920fc54826c2a0015ab3a19b7b873d208653.tar.bz2 |
Bugfixes for pe_print_debugdata()
Use a separate iteration variable for inner loop (:blush:). This
generally prevented any debug directory entries after a
IMAGE_DEBUG_TYPE_CODEVIEW entry from being reported.
Don't leak the memory allocated for the section containing the debug
directory.
bfd/ChangeLog:
2020-01-16 Jon Turney <jon.turney@dronecode.org.uk>
* peXXigen.c (pe_print_debugdata): Fix the iteration variable for
inner loop. Fix a memory leak.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/peXXigen.c | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1e2740e..58af683 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2020-01-16 Jon Turney <jon.turney@dronecode.org.uk> + + * peXXigen.c (pe_print_debugdata): Fix the iteration variable for + inner loop. Fix a memory leak. + 2020-01-30 Alan Modra <amodra@gmail.com> * coffgen.c (coff_real_object_p): Don't clear obj_coff_keep_syms diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index c5082a7..ac0cf17 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -2630,7 +2630,7 @@ pe_print_debugdata (bfd * abfd, void * vfile) asection *section; bfd_byte *data = 0; bfd_size_type dataoff; - unsigned int i; + unsigned int i, j; bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; @@ -2722,8 +2722,8 @@ pe_print_debugdata (bfd * abfd, void * vfile) idd.SizeOfData, cvinfo)) continue; - for (i = 0; i < cvinfo->SignatureLength; i++) - sprintf (&signature[i*2], "%02x", cvinfo->Signature[i] & 0xff); + for (j = 0; j < cvinfo->SignatureLength; j++) + sprintf (&signature[j*2], "%02x", cvinfo->Signature[j] & 0xff); /* xgettext:c-format */ fprintf (file, _("(format %c%c%c%c signature %s age %ld)\n"), @@ -2732,6 +2732,8 @@ pe_print_debugdata (bfd * abfd, void * vfile) } } + free(data); + if (size % sizeof (struct external_IMAGE_DEBUG_DIRECTORY) != 0) fprintf (file, _("The debug directory size is not a multiple of the debug directory entry size\n")); |