public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch 4/4] Fix references past allocated memory for i386-*-go32
@ 2009-08-09 21:40 Jan Kratochvil
  2009-08-10 15:05 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2009-08-09 21:40 UTC (permalink / raw)
  To: binutils

Hi,

while sanity checking my changes by valgrind I got this error, in fact
unrelated to my previous patches:

Invalid read of size 1
   at 0x43CF59: bfd_getb16 (libbfd.c:553)
   by 0x5B892D: coff_swap_filehdr_in (coffswap.h:274)
   by 0x437D4F: coff_object_p (coffgen.c:265)
   by 0x43C5E4: bfd_check_format_matches (format.c:211)
   by 0x4061B2: copy_file (objcopy.c:2210)
   by 0x409687: copy_main (objcopy.c:3865)
   by 0x409968: main (objcopy.c:3961)
 Address 0x4c2b90c is 0 bytes after a block of size 20 alloc'd
   at 0x4A0763E: malloc (vg_replace_malloc.c:207)
   by 0x43CB6A: bfd_malloc (libbfd.c:173)
   by 0x437CB8: coff_object_p (coffgen.c:255)
   by 0x43C5E4: bfd_check_format_matches (format.c:211)
   by 0x4061B2: copy_file (objcopy.c:2210)
   by 0x409687: copy_main (objcopy.c:3865)
   by 0x409968: main (objcopy.c:3961)

The patched code may be somehow duplicate to this coff_swap_filehdr_in() line
but that duplicity removal is IMO for some other patch.

#ifdef TIC80_TARGET_ID
  filehdr_dst->f_target_id = H_GET_16 (abfd, filehdr_src->f_target_id);
#endif


Thanks,
Jan


include/coff/
2009-08-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix references past allocated memory for i386-*-go32.
	* ti.h (COFF_ADJUST_FILEHDR_IN_POST, COFF_ADJUST_FILEHDR_OUT_POST):
	Reference F_TARGET_ID only when !COFF0_P.

--- include/coff/ti.h	23 Dec 2008 10:59:56 -0000	1.19
+++ include/coff/ti.h	9 Aug 2009 10:37:55 -0000
@@ -102,19 +102,21 @@ struct external_filehdr
 #define COFF_ADJUST_FILEHDR_IN_POST(abfd, src, dst) \
   do									\
     {									\
-      ((struct internal_filehdr *)(dst))->f_target_id =			\
-	H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id);		\
+      if (!COFF0_P (abfd))						\
+	((struct internal_filehdr *)(dst))->f_target_id =		\
+	  H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id);		\
     }									\
   while (0)
 #endif
 
 #ifndef COFF_ADJUST_FILEHDR_OUT_POST
 #define COFF_ADJUST_FILEHDR_OUT_POST(abfd, src, dst) \
-  do									\
-    {									\
-      H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id,	\
-	       ((FILHDR *)(dst))->f_target_id);				\
-    }									\
+  do									 \
+    {									 \
+      if (!COFF0_P (abfd))						 \
+	H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id, \
+		 ((FILHDR *)(dst))->f_target_id);			 \
+    }									 \
   while (0)
 #endif
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch 4/4] Fix references past allocated memory for i386-*-go32
  2009-08-09 21:40 [patch 4/4] Fix references past allocated memory for i386-*-go32 Jan Kratochvil
@ 2009-08-10 15:05 ` Nick Clifton
  2009-08-10 22:03   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2009-08-10 15:05 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: binutils

Hi Jan,

> include/coff/
> 2009-08-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Fix references past allocated memory for i386-*-go32.
> 	* ti.h (COFF_ADJUST_FILEHDR_IN_POST, COFF_ADJUST_FILEHDR_OUT_POST):
> 	Reference F_TARGET_ID only when !COFF0_P.

Approved - please apply.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch 4/4] Fix references past allocated memory for  i386-*-go32
  2009-08-10 15:05 ` Nick Clifton
@ 2009-08-10 22:03   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2009-08-10 22:03 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Hi Nick,

On Mon, 10 Aug 2009 17:05:10 +0200, Nick Clifton wrote:
>> include/coff/
>> 2009-08-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
>>
>> 	Fix references past allocated memory for i386-*-go32.
>> 	* ti.h (COFF_ADJUST_FILEHDR_IN_POST, COFF_ADJUST_FILEHDR_OUT_POST):
>> 	Reference F_TARGET_ID only when !COFF0_P.
>
> Approved - please apply.

Checked-in:
	http://sourceware.org/ml/binutils-cvs/2009-08/msg00066.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-10 22:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-09 21:40 [patch 4/4] Fix references past allocated memory for i386-*-go32 Jan Kratochvil
2009-08-10 15:05 ` Nick Clifton
2009-08-10 22:03   ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).