This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] objcopy Segmentation fault
- From: Hideki IWAMOTO <h-iwamoto at kit dot hi-ho dot ne dot jp>
- To: binutils at sources dot redhat dot com
- Date: Tue, 02 Apr 2002 22:48:37 +0900
- Subject: [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