From ee7da987c93489fb4c8f56ce32a1d0d56a48b2ea Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 7 Nov 2012 06:16:26 +0000 Subject: Don't read beyond section end * objcopy.c (copy_section): Don't read beyond section end. --- binutils/ChangeLog | 4 ++++ binutils/objcopy.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 84ea185..688d569 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2012-11-07 H.J. Lu + + * objcopy.c (copy_section): Don't read beyond section end. + 2012-11-06 H.J. Lu PR binutils/14567 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; -- cgit v1.1