public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] elf32-i386.c, check for null
@ 2007-07-26  1:32 msnyder
  2007-07-26  6:18 ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: msnyder @ 2007-07-26  1:32 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 125 bytes --]

The function checks for h == NULL elsewhere, I assume it needs to
be checked here too (since the call will dereference it).


[-- Attachment #2: h.txt --]
[-- Type: text/plain, Size: 1043 bytes --]

2007-07-25  Michael Snyder  <msnyder@access-company.com>

	* elf32-i386.c (elf_i386_check_relocs): Check for null pointer.

Index: elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.174
diff -p -r1.174 elf32-i386.c
*** elf32-i386.c	3 Jul 2007 14:26:41 -0000	1.174
--- elf32-i386.c	26 Jul 2007 01:20:28 -0000
*************** elf_i386_check_relocs (bfd *abfd,
*** 1277,1284 ****
  	  /* This relocation describes which C++ vtable entries are actually
  	     used.  Record for later use during GC.  */
  	case R_386_GNU_VTENTRY:
! 	  if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
! 	    return FALSE;
  	  break;
  
  	default:
--- 1277,1285 ----
  	  /* This relocation describes which C++ vtable entries are actually
  	     used.  Record for later use during GC.  */
  	case R_386_GNU_VTENTRY:
! 	  if (h != NULL)
! 	    if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
! 	      return FALSE;
  	  break;
  
  	default:

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

* Re: [patch] elf32-i386.c, check for null
  2007-07-26  1:32 [patch] elf32-i386.c, check for null msnyder
@ 2007-07-26  6:18 ` H.J. Lu
  2007-07-27  1:57   ` msnyder
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2007-07-26  6:18 UTC (permalink / raw)
  To: msnyder; +Cc: binutils

On Wed, Jul 25, 2007 at 06:23:28PM -0700, msnyder@sonic.net wrote:
> The function checks for h == NULL elsewhere, I assume it needs to
> be checked here too (since the call will dereference it).
> 

> 2007-07-25  Michael Snyder  <msnyder@access-company.com>
> 
> 	* elf32-i386.c (elf_i386_check_relocs): Check for null pointer.
> 
> Index: elf32-i386.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf32-i386.c,v
> retrieving revision 1.174
> diff -p -r1.174 elf32-i386.c
> *** elf32-i386.c	3 Jul 2007 14:26:41 -0000	1.174
> --- elf32-i386.c	26 Jul 2007 01:20:28 -0000
> *************** elf_i386_check_relocs (bfd *abfd,
> *** 1277,1284 ****
>   	  /* This relocation describes which C++ vtable entries are actually
>   	     used.  Record for later use during GC.  */
>   	case R_386_GNU_VTENTRY:
> ! 	  if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
> ! 	    return FALSE;
>   	  break;
>   
>   	default:
> --- 1277,1285 ----
>   	  /* This relocation describes which C++ vtable entries are actually
>   	     used.  Record for later use during GC.  */
>   	case R_386_GNU_VTENTRY:
> ! 	  if (h != NULL)
> ! 	    if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
> ! 	      return FALSE;
>   	  break;
>   
>   	default:

I prefer BFD_ASSERT (h != NULL) and R_386_GNU_VTINHERIT has the same
issue. 


H.J.

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

* Re: [patch] elf32-i386.c, check for null
  2007-07-26  6:18 ` H.J. Lu
@ 2007-07-27  1:57   ` msnyder
  2007-07-27  4:46     ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: msnyder @ 2007-07-27  1:57 UTC (permalink / raw)
  To: H.J. Lu; +Cc: msnyder, binutils

[-- Attachment #1: Type: text/plain, Size: 103 bytes --]


>
> I prefer BFD_ASSERT (h != NULL) and R_386_GNU_VTINHERIT has the same
> issue.

OK -- how's this?


[-- Attachment #2: h2.txt --]
[-- Type: text/plain, Size: 1631 bytes --]

2007-07-25  Michael Snyder  <msnyder@access-company.com>

	* elf32-i386.c (elf_i386_check_relocs): Check for null pointer.

Index: elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.174
diff -p -r1.174 elf32-i386.c
*** elf32-i386.c	3 Jul 2007 14:26:41 -0000	1.174
--- elf32-i386.c	27 Jul 2007 01:40:47 -0000
*************** elf_i386_check_relocs (bfd *abfd,
*** 1270,1284 ****
  	  /* This relocation describes the C++ object vtable hierarchy.
  	     Reconstruct it for later use during GC.  */
  	case R_386_GNU_VTINHERIT:
! 	  if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
! 	    return FALSE;
  	  break;
  
  	  /* This relocation describes which C++ vtable entries are actually
  	     used.  Record for later use during GC.  */
  	case R_386_GNU_VTENTRY:
! 	  if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
! 	    return FALSE;
  	  break;
  
  	default:
--- 1270,1288 ----
  	  /* This relocation describes the C++ object vtable hierarchy.
  	     Reconstruct it for later use during GC.  */
  	case R_386_GNU_VTINHERIT:
! 	  BFD_ASSERT (h != NULL);
! 	  if (h != NULL)
! 	    if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
! 	      return FALSE;
  	  break;
  
  	  /* This relocation describes which C++ vtable entries are actually
  	     used.  Record for later use during GC.  */
  	case R_386_GNU_VTENTRY:
! 	  BFD_ASSERT (h != NULL);
! 	  if (h != NULL)
! 	    if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
! 	      return FALSE;
  	  break;
  
  	default:

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

* Re: [patch] elf32-i386.c, check for null
  2007-07-27  1:57   ` msnyder
@ 2007-07-27  4:46     ` H.J. Lu
  2007-07-27 18:54       ` msnyder
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2007-07-27  4:46 UTC (permalink / raw)
  To: msnyder; +Cc: binutils

On Thu, Jul 26, 2007 at 06:42:01PM -0700, msnyder@sonic.net wrote:
> 
> >
> > I prefer BFD_ASSERT (h != NULL) and R_386_GNU_VTINHERIT has the same
> > issue.
> 
> OK -- how's this?
> 

> 2007-07-25  Michael Snyder  <msnyder@access-company.com>
> 
> 	* elf32-i386.c (elf_i386_check_relocs): Check for null pointer.
> 
> Index: elf32-i386.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf32-i386.c,v
> retrieving revision 1.174
> diff -p -r1.174 elf32-i386.c
> *** elf32-i386.c	3 Jul 2007 14:26:41 -0000	1.174
> --- elf32-i386.c	27 Jul 2007 01:40:47 -0000
> *************** elf_i386_check_relocs (bfd *abfd,
> *** 1270,1284 ****
>   	  /* This relocation describes the C++ object vtable hierarchy.
>   	     Reconstruct it for later use during GC.  */
>   	case R_386_GNU_VTINHERIT:
> ! 	  if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
> ! 	    return FALSE;
>   	  break;
>   
>   	  /* This relocation describes which C++ vtable entries are actually
>   	     used.  Record for later use during GC.  */
>   	case R_386_GNU_VTENTRY:
> ! 	  if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
> ! 	    return FALSE;
>   	  break;
>   
>   	default:
> --- 1270,1288 ----
>   	  /* This relocation describes the C++ object vtable hierarchy.
>   	     Reconstruct it for later use during GC.  */
>   	case R_386_GNU_VTINHERIT:
> ! 	  BFD_ASSERT (h != NULL);
> ! 	  if (h != NULL)
> ! 	    if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
> ! 	      return FALSE;
>   	  break;
>   
>   	  /* This relocation describes which C++ vtable entries are actually
>   	     used.  Record for later use during GC.  */
>   	case R_386_GNU_VTENTRY:
> ! 	  BFD_ASSERT (h != NULL);
> ! 	  if (h != NULL)
> ! 	    if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
> ! 	      return FALSE;
>   	  break;
>   

It is OK.  Can you use

if (h != NULL
    && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
   return FALSE;

2 ifs look odd to me. But it is OK if you don't want to change.

Thanks.


H.J.

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

* Re: [patch] elf32-i386.c, check for null
  2007-07-27  4:46     ` H.J. Lu
@ 2007-07-27 18:54       ` msnyder
  0 siblings, 0 replies; 5+ messages in thread
From: msnyder @ 2007-07-27 18:54 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

> On Thu, Jul 26, 2007 at 06:42:01PM -0700, msnyder@sonic.net wrote:

>
> It is OK.  Can you use
>
> if (h != NULL
>     && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
>    return FALSE;
>

Yep, done and committed.
Thanks.


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

end of thread, other threads:[~2007-07-27 18:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26  1:32 [patch] elf32-i386.c, check for null msnyder
2007-07-26  6:18 ` H.J. Lu
2007-07-27  1:57   ` msnyder
2007-07-27  4:46     ` H.J. Lu
2007-07-27 18:54       ` msnyder

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).