public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] aout relocs
@ 2007-07-25 20:10 msnyder
  2007-07-25 20:37 ` Ian Lance Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: msnyder @ 2007-07-25 20:10 UTC (permalink / raw)
  To: binutils

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

Check me on this one, I'm a little uncertain.

As near as I can tell, if reloc_size is zero, the routine does
nothing useful.  Maybe it will never be zero, but if it is, a few
iffy things will happen:

 * we'll call malloc with a size of zero, which is ill defined,
and later free the result

 * we'll call bfd_bread with a size of zero, and

 * a potentially null pointer may slip thru the cracks.


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

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

	* aoutx.h (NAME): Return TRUE if reloc_size is zero.

Index: aoutx.h
===================================================================
RCS file: /cvs/src/src/bfd/aoutx.h,v
retrieving revision 1.66
diff -p -r1.66 aoutx.h
*** aoutx.h	3 Jul 2007 14:26:39 -0000	1.66
--- aoutx.h	25 Jul 2007 18:59:09 -0000
*************** NAME (aout, slurp_reloc_table) (bfd *abf
*** 2280,2285 ****
--- 2280,2288 ----
        return FALSE;
      }
  
+   if (reloc_size == 0)
+     return TRUE;		/* Nothing to be done.  */
+ 
    if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
      return FALSE;
  
*************** NAME (aout, slurp_reloc_table) (bfd *abf
*** 2289,2299 ****
  
    amt = count * sizeof (arelent);
    reloc_cache = bfd_zmalloc (amt);
!   if (reloc_cache == NULL && count != 0)
      return FALSE;
  
    relocs = bfd_malloc (reloc_size);
!   if (relocs == NULL && reloc_size != 0)
      {
        free (reloc_cache);
        return FALSE;
--- 2292,2302 ----
  
    amt = count * sizeof (arelent);
    reloc_cache = bfd_zmalloc (amt);
!   if (reloc_cache == NULL)
      return FALSE;
  
    relocs = bfd_malloc (reloc_size);
!   if (relocs == NULL)
      {
        free (reloc_cache);
        return FALSE;

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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-25 20:10 [PATCH] aout relocs msnyder
2007-07-25 20:37 ` Ian Lance Taylor
2007-07-25 21:23   ` msnyder
2007-07-25 21:31     ` Andreas Schwab
2007-07-25 21:51       ` msnyder
2007-07-26  9:37         ` Nick Clifton
2007-07-26 18:43           ` 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).