mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
Check file size before getting section contents
Don't check the section size in bfd_get_full_section_contents since the size of a decompressed section may be larger than the file size. Instead, check file size in _bfd_generic_get_section_contents. PR binutils/21665 * compress.c (bfd_get_full_section_contents): Don't check the file size here. * libbfd.c (_bfd_generic_get_section_contents): Check for and reject a section whoes size + offset is greater than the size of the entire file. (_bfd_generic_get_section_contents_in_window): Likewise.
This commit is contained in:
@@ -239,12 +239,6 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
|
||||
*ptr = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
else if (bfd_get_file_size (abfd) > 0
|
||||
&& sz > (bfd_size_type) bfd_get_file_size (abfd))
|
||||
{
|
||||
*ptr = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (sec->compress_status)
|
||||
{
|
||||
@@ -260,7 +254,7 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
|
||||
/* xgettext:c-format */
|
||||
(_("error: %B(%A) is too large (%#lx bytes)"),
|
||||
abfd, sec, (long) sz);
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user