Blob Blame History Raw
*** ../binutils-2.24.orig/bfd/srec.c	2014-10-24 15:34:34.156138230 +0100
--- bfd/srec.c	2014-10-24 15:42:41.462592601 +0100
*************** srec_scan (bfd *abfd)
*** 455,461 ****
  	  {
  	    file_ptr pos;
  	    char hdr[3];
! 	    unsigned int bytes;
  	    bfd_vma address;
  	    bfd_byte *data;
  	    unsigned char check_sum;
--- 455,461 ----
  	  {
  	    file_ptr pos;
  	    char hdr[3];
! 	    unsigned int bytes, min_bytes;
  	    bfd_vma address;
  	    bfd_byte *data;
  	    unsigned char check_sum;
*************** srec_scan (bfd *abfd)
*** 478,483 ****
--- 478,496 ----
  	      }
  
  	    check_sum = bytes = HEX (hdr + 1);
+ 	    min_bytes = 3;
+ 	    if (hdr[0] == '2' || hdr[0] == '8')
+ 	      min_bytes = 4;
+ 	    else if (hdr[0] == '3' || hdr[0] == '7')
+ 	      min_bytes = 5;
+ 	    if (bytes < min_bytes)
+ 	      {
+ 		(*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"),
+ 				       abfd, lineno, bytes);
+ 		bfd_set_error (bfd_error_bad_value);
+ 		goto error_return;
+ 	      }
+ 
  	    if (bytes * 2 > bufsize)
  	      {
  		if (buf != NULL)