- size = bfd_section_size (abfd, sec);
- data = (bfd_byte *) res_alloc (size);
+ size = bfd_section_size (sec);
+ /* PR 17512: file: 1b25ba5d
+ The call to get_file_size here may be expensive
+ but there is no other way to determine if the section size
+ is reasonable. */
+ if (size > (bfd_size_type) get_file_size (filename))
+ fatal (_("%s: .rsrc section is bigger than the file!"), filename);