aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-11-07 06:16:26 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-11-07 06:16:26 +0000
commitee7da987c93489fb4c8f56ce32a1d0d56a48b2ea (patch)
treeed0cd4c07467bd6d6eaa48a18cc2fe417f04e487 /binutils/objcopy.c
parentddda4adc286e6a6e37702141f891a04552f18006 (diff)
downloadgdb-ee7da987c93489fb4c8f56ce32a1d0d56a48b2ea.zip
gdb-ee7da987c93489fb4c8f56ce32a1d0d56a48b2ea.tar.gz
gdb-ee7da987c93489fb4c8f56ce32a1d0d56a48b2ea.tar.bz2
Don't read beyond section end
* objcopy.c (copy_section): Don't read beyond section end.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index f44ebcd..4860864 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2823,7 +2823,11 @@ copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
for (; from < end; from += interleave)
for (i = 0; i < copy_width; i++)
- *to++ = from[i];
+ {
+ if (&from[i] >= end)
+ break;
+ *to++ = from[i];
+ }
size = (size + interleave - 1 - copy_byte) / interleave * copy_width;
osection->lma /= interleave;