This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] objcopy Segmentation fault



iwamoto@alpha:/tmp>objcopy -O srec --srec-len=121 a a.srec
Segmentation fault (core dumped)

Index: srec.c
===================================================================
RCS file: /cvs/src/src/bfd/srec.c,v
retrieving revision 1.15
diff -u -r1.15 srec.c
--- srec.c	2002/01/06 07:30:35	1.15
+++ srec.c	2002/04/02 13:24:37
@@ -1013,6 +1013,7 @@
 {
   unsigned int octets_written = 0;
   bfd_byte *location = list->data;
+  unsigned int chunk_limit = MAXCHUNK / 2 - 5 - tdata->type;
 
   while (octets_written < list->size)
     {
@@ -1021,6 +1022,10 @@
 
       if (octets_this_chunk > Chunk)
 	octets_this_chunk = Chunk;
+
+      /* avoid buffer overflow */
+      if (octets_this_chunk > chunk_limit)
+	octets_this_chunk = chunk_limit;
 
       address = list->where + octets_written / bfd_octets_per_byte (abfd);
 

----
Hideki IWAMOTO  h-iwamoto@kit.hi-ho.ne.jp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]