:: commit 359cdb08f63f91c5d52b33d16c76ca4d3f9e4cac

N00byEdge <hannesbredberg@gmail.com> — 2020-06-01 07:02

parents: b08abed015

Fixed stack smashing with fread()

diff --git a/src/lib/elf.c b/src/lib/elf.c
index d5dcb8ea..8440c82e 100644
--- a/src/lib/elf.c
+++ b/src/lib/elf.c
@@ -153,7 +153,7 @@ static int elf64_apply_relocations(struct file_handle *fd, struct elf64_hdr *hdr
         // This is a RELA header, get and apply all relocations
         for (uint64_t offset = 0; offset < section.sh_size; offset += section.sh_entsize) {
             struct elf64_rela relocation;
-            fread(fd, &relocation, section.sh_offset + offset, section.sh_size);
+            fread(fd, &relocation, section.sh_offset + offset, sizeof(relocation));
 
             switch (relocation.r_info) {
                 case R_X86_64_RELATIVE:
tab: 248 wrap: offon