PR29482 - strip: heap-buffer-overflow

PR 29482
	* coffcode.h (coff_set_section_contents): Sanity check _LIB.
This commit is contained in:
Alan Modra
2022-08-13 15:32:47 +09:30
parent 8007515072
commit ef186fe54a
+5 -2
View File
@@ -4302,10 +4302,13 @@ coff_set_section_contents (bfd * abfd,
rec = (bfd_byte *) location;
recend = rec + count;
while (rec < recend)
while (recend - rec >= 4)
{
size_t len = bfd_get_32 (abfd, rec);
if (len == 0 || len > (size_t) (recend - rec) / 4)
break;
rec += len * 4;
++section->lma;
rec += bfd_get_32 (abfd, rec) * 4;
}
BFD_ASSERT (rec == recend);