Lines 608-616
setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
Link Here
|
608 |
if (shdr->contents == NULL) |
608 |
if (shdr->contents == NULL) |
609 |
{ |
609 |
{ |
610 |
_bfd_error_handler |
610 |
_bfd_error_handler |
611 |
(_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); |
611 |
(_("%B: corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); |
612 |
bfd_set_error (bfd_error_bad_value); |
612 |
bfd_set_error (bfd_error_bad_value); |
613 |
return FALSE; |
613 |
-- num_group; |
|
|
614 |
continue; |
614 |
} |
615 |
} |
615 |
|
616 |
|
616 |
memset (shdr->contents, 0, amt); |
617 |
memset (shdr->contents, 0, amt); |
Lines 618-625
setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
Link Here
|
618 |
if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0 |
619 |
if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0 |
619 |
|| (bfd_bread (shdr->contents, shdr->sh_size, abfd) |
620 |
|| (bfd_bread (shdr->contents, shdr->sh_size, abfd) |
620 |
!= shdr->sh_size)) |
621 |
!= shdr->sh_size)) |
621 |
return FALSE; |
622 |
{ |
622 |
|
623 |
_bfd_error_handler |
|
|
624 |
(_("%B: invalid size field in group section header: 0x%lx"), abfd, shdr->sh_size); |
625 |
bfd_set_error (bfd_error_bad_value); |
626 |
-- num_group; |
627 |
/* PR 17510: If the group contents are even partially |
628 |
corrupt, do not allow any of the contents to be used. */ |
629 |
memset (shdr->contents, 0, amt); |
630 |
continue; |
631 |
} |
632 |
|
623 |
/* Translate raw contents, a flag word followed by an |
633 |
/* Translate raw contents, a flag word followed by an |
624 |
array of elf section indices all in target byte order, |
634 |
array of elf section indices all in target byte order, |
625 |
to the flag word followed by an array of elf section |
635 |
to the flag word followed by an array of elf section |
Lines 651-656
setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
Link Here
|
651 |
} |
661 |
} |
652 |
} |
662 |
} |
653 |
} |
663 |
} |
|
|
664 |
|
665 |
/* PR 17510: Corrupt binaries might contain invalid groups. */ |
666 |
if (num_group != (unsigned) elf_tdata (abfd)->num_group) |
667 |
{ |
668 |
elf_tdata (abfd)->num_group = num_group; |
669 |
|
670 |
/* If all groups are invalid then fail. */ |
671 |
if (num_group == 0) |
672 |
{ |
673 |
elf_tdata (abfd)->group_sect_ptr = NULL; |
674 |
elf_tdata (abfd)->num_group = num_group = -1; |
675 |
(*_bfd_error_handler) (_("%B: no valid group sections found"), abfd); |
676 |
bfd_set_error (bfd_error_bad_value); |
677 |
} |
678 |
} |
654 |
} |
679 |
} |
655 |
} |
680 |
} |
656 |
|
681 |
|
Lines 716-721
setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
Link Here
|
716 |
{ |
741 |
{ |
717 |
(*_bfd_error_handler) (_("%B: no group info for section %A"), |
742 |
(*_bfd_error_handler) (_("%B: no group info for section %A"), |
718 |
abfd, newsect); |
743 |
abfd, newsect); |
|
|
744 |
return FALSE; |
719 |
} |
745 |
} |
720 |
return TRUE; |
746 |
return TRUE; |
721 |
} |
747 |
} |