UB in coff_compute_section_file_positions
Checks
Commit Message
objcopy with an input having fuzzed section alignment can result in
trying to align sections to large boundaries, ones that result in
file_ptr overflow since the type is signed. Fix this by using
ufile_ptr. I don't care to catch ufile_ptr overflow and report an
error as fuzzed objects are a case of garbage in garbage out.
@@ -2986,12 +2986,12 @@ static bool
coff_compute_section_file_positions (bfd * abfd)
{
asection *current;
- file_ptr sofar = bfd_coff_filhsz (abfd);
+ ufile_ptr sofar = bfd_coff_filhsz (abfd);
bool align_adjust;
unsigned int target_index;
#ifdef ALIGN_SECTIONS_IN_FILE
asection *previous = NULL;
- file_ptr old_sofar;
+ ufile_ptr old_sofar;
#endif
#ifdef COFF_IMAGE_WITH_PE