public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] srec_scan, check for EOF
@ 2007-07-26  0:21 msnyder
  2007-07-26 13:05 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: msnyder @ 2007-07-26  0:21 UTC (permalink / raw)
  To: binutils

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

If we miss an EOF here, it'll be used as an array index and probably
cause a segfault.


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

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

	* srec.c (srec_scan): Check for EOF (critical because return value
	will be used as array index).

Index: srec.c
===================================================================
RCS file: /cvs/src/src/bfd/srec.c,v
retrieving revision 1.42
diff -p -5 -r1.42 srec.c
*** srec.c	3 Jul 2007 14:26:42 -0000	1.42
--- srec.c	26 Jul 2007 00:03:57 -0000
*************** srec_scan (bfd *abfd)
*** 426,435 ****
--- 426,440 ----
  	      while (ISHEX (c))
  		{
  		  symval <<= 4;
  		  symval += NIBBLE (c);
  		  c = srec_get_byte (abfd, &error);
+ 		  if (c == EOF)
+ 		    {
+ 		      srec_bad_byte (abfd, lineno, c, error);
+ 		      goto error_return;
+ 		    }
  		}
  
  	      if (! srec_new_symbol (abfd, symname, symval))
  		goto error_return;
  	    }

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

* Re: [PATCH] srec_scan, check for EOF
  2007-07-26  0:21 [PATCH] srec_scan, check for EOF msnyder
@ 2007-07-26 13:05 ` Alan Modra
  2007-07-26 18:52   ` msnyder
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2007-07-26 13:05 UTC (permalink / raw)
  To: msnyder; +Cc: binutils

On Wed, Jul 25, 2007 at 05:06:26PM -0700, msnyder@sonic.net wrote:
> 	* srec.c (srec_scan): Check for EOF (critical because return value
> 	will be used as array index).

OK.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [PATCH] srec_scan, check for EOF
  2007-07-26 13:05 ` Alan Modra
@ 2007-07-26 18:52   ` msnyder
  0 siblings, 0 replies; 3+ messages in thread
From: msnyder @ 2007-07-26 18:52 UTC (permalink / raw)
  To: binutils

> On Wed, Jul 25, 2007 at 05:06:26PM -0700, msnyder@sonic.net wrote:
>> 	* srec.c (srec_scan): Check for EOF (critical because return value
>> 	will be used as array index).
>
> OK.

Committed, thanks.


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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26  0:21 [PATCH] srec_scan, check for EOF msnyder
2007-07-26 13:05 ` Alan Modra
2007-07-26 18:52   ` 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).