This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: two patches for bugs in BFD/peXXigen.c
On Mon, Sep 06, 2010 at 10:55:08AM +0200, Kai Tietz wrote:
> Would it be possible to get it without whitespace changes? 80% of it
Index: bfd/peXXigen.c
===================================================================
RCS file: /cvs/src/src/bfd/peXXigen.c,v
retrieving revision 1.64
diff -u -p -w -r1.64 peXXigen.c
--- bfd/peXXigen.c 27 Jun 2010 04:07:53 -0000 1.64
+++ bfd/peXXigen.c 6 Sep 2010 10:15:02 -0000
@@ -1223,7 +1223,7 @@ pe_print_idata (bfd * abfd, void * vfile
bfd_byte *ft_data;
asection *ft_section;
bfd_vma ft_addr;
- bfd_size_type ft_datasize;
+ bfd_size_type ft_datasize = 0;
int ft_idx;
int ft_allocated = 0;
@@ -1234,6 +1234,7 @@ pe_print_idata (bfd * abfd, void * vfile
ft_addr = first_thunk + extra->ImageBase;
ft_data = data;
ft_idx = first_thunk - adj;
+ ft_datasize = section->size - ft_idx;
ft_allocated = 0;
if (first_thunk != hint_addr)
@@ -1242,12 +1243,9 @@ pe_print_idata (bfd * abfd, void * vfile
for (ft_section = abfd->sections;
ft_section != NULL;
ft_section = ft_section->next)
- {
- ft_datasize = ft_section->size;
if (ft_addr >= ft_section->vma
- && ft_addr < ft_section->vma + ft_datasize)
+ && ft_addr < ft_section->vma + ft_section->size)
break;
- }
if (ft_section == NULL)
{
@@ -1258,21 +1256,17 @@ pe_print_idata (bfd * abfd, void * vfile
/* Now check to see if this section is the same as our current
section. If it is not then we will have to load its data in. */
- if (ft_section == section)
- {
- ft_data = data;
- ft_idx = first_thunk - adj;
- }
- else
+ if (ft_section != section)
{
ft_idx = first_thunk - (ft_section->vma - extra->ImageBase);
- ft_data = (bfd_byte *) bfd_malloc (datasize);
+ ft_datasize = ft_section->size - ft_idx;
+ ft_data = (bfd_byte *) bfd_malloc (ft_datasize);
if (ft_data == NULL)
continue;
- /* Read datasize bfd_bytes starting at offset ft_idx. */
- if (! bfd_get_section_contents
- (abfd, ft_section, ft_data, (bfd_vma) ft_idx, datasize))
+ /* Read ft_datasize bytes starting at offset ft_idx. */
+ if (!bfd_get_section_contents (abfd, ft_section, ft_data,
+ (bfd_vma) ft_idx, ft_datasize))
{
free (ft_data);
continue;
@@ -1310,7 +1304,8 @@ pe_print_idata (bfd * abfd, void * vfile
table holds actual addresses. */
if (time_stamp != 0
&& first_thunk != 0
- && first_thunk != hint_addr)
+ && first_thunk != hint_addr
+ && j + 4 <= ft_datasize)
fprintf (file, "\t%04lx",
(unsigned long) bfd_get_32 (abfd, ft_data + ft_idx + j));
fprintf (file, "\n");
@@ -1342,7 +1337,8 @@ pe_print_idata (bfd * abfd, void * vfile
table holds actual addresses. */
if (time_stamp != 0
&& first_thunk != 0
- && first_thunk != hint_addr)
+ && first_thunk != hint_addr
+ && j + 4 <= ft_datasize)
fprintf (file, "\t%04lx",
(unsigned long) bfd_get_32 (abfd, ft_data + ft_idx + j));
@@ -1828,7 +1824,6 @@ _bfd_XX_print_ce_compressed_pdata (bfd *
bfd_vma other_data;
bfd_vma prolog_length, function_length;
int flag32bit, exception_flag;
- bfd_byte *tdata = 0;
asection *tsection;
if (i + PDATA_ROW_SIZE > stop)
@@ -1860,12 +1855,14 @@ _bfd_XX_print_ce_compressed_pdata (bfd *
if (tsection && coff_section_data (abfd, tsection)
&& pei_section_data (abfd, tsection))
{
- if (bfd_malloc_and_get_section (abfd, tsection, & tdata))
- {
int xx = (begin_addr - 8) - tsection->vma;
+ bfd_byte *tdata;
tdata = (bfd_byte *) bfd_malloc (8);
- if (bfd_get_section_contents (abfd, tsection, tdata, (bfd_vma) xx, 8))
+ if (tdata)
+ {
+ if (bfd_get_section_contents (abfd, tsection,
+ tdata, (bfd_vma) xx, 8))
{
bfd_vma eh, eh_data;
@@ -1883,11 +1880,6 @@ _bfd_XX_print_ce_compressed_pdata (bfd *
}
free (tdata);
}
- else
- {
- if (tdata)
- free (tdata);
- }
}
fprintf (file, "\n");
--
Alan Modra
Australia Development Lab, IBM