(bfd_get_section_contents): Since this function reads unrelocated contents, the
authorKen Raeburn <raeburn@cygnus>
Wed, 16 Feb 1994 00:57:15 +0000 (00:57 +0000)
committerKen Raeburn <raeburn@cygnus>
Wed, 16 Feb 1994 00:57:15 +0000 (00:57 +0000)
section's raw size is always the one to use for bounds checking.

bfd/section.c

index 02ae2188458bb89e708ea9a7f87b7cea4d641967..373e7a00d3a8ef8795c869f97da687cc9e7e116e 100644 (file)
@@ -887,10 +887,10 @@ DEFUN(bfd_get_section_contents,(abfd, section, location, offset, count),
       bfd_error = bad_value;
       return false;
     }
-  sz = bfd_get_section_size_now (abfd, section);
-  if (offset > sz
-      || count > sz
-      || offset + count > sz)
+  /* Even if reloc_done is true, this function reads unrelocated
+     contents, so we want the raw size.  */
+  sz = section->_raw_size;
+  if (offset > sz || count > sz || offset + count > sz)
     goto bad_val;
 
   if (count == 0)