mingw-binutils/CVE-2022-38533.patch
Richard W.M. Jones 2f99a5c952 Rebase to Fedora Rawhide
resolves: rhbz#2135769
side-tag: c9s-build-side-1410-stack-gate
2023-01-03 08:53:43 +00:00

20 lines
647 B
Diff

diff -rupN --no-dereference binutils-2.39/bfd/coffcode.h binutils-2.39-new/bfd/coffcode.h
--- binutils-2.39/bfd/coffcode.h 2022-07-08 11:46:47.000000000 +0200
+++ binutils-2.39-new/bfd/coffcode.h 2022-10-30 12:41:41.408023817 +0100
@@ -4284,10 +4284,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);