Fix bug in elf lib where a very large buffer could be accidentally allocated on the stack

This commit is contained in:
mintsuki 2020-10-24 15:27:30 +02:00
parent 01399b2e49
commit 7867d23e45
2 changed files with 2 additions and 2 deletions

Binary file not shown.

View File

@ -206,7 +206,7 @@ int elf64_load_section(struct file_handle *fd, void *buffer, const char *name, s
fread(fd, &shstrtab, hdr.shoff + hdr.shstrndx * sizeof(struct elf64_shdr),
sizeof(struct elf64_shdr));
char names[shstrtab.sh_size];
char *names = ext_mem_alloc(shstrtab.sh_size);
fread(fd, names, shstrtab.sh_offset, shstrtab.sh_size);
for (uint16_t i = 0; i < hdr.sh_num; i++) {
@ -250,7 +250,7 @@ int elf32_load_section(struct file_handle *fd, void *buffer, const char *name, s
fread(fd, &shstrtab, hdr.shoff + hdr.shstrndx * sizeof(struct elf32_shdr),
sizeof(struct elf32_shdr));
char names[shstrtab.sh_size];
char *names = ext_mem_alloc(shstrtab.sh_size);
fread(fd, names, shstrtab.sh_offset, shstrtab.sh_size);
for (uint16_t i = 0; i < hdr.sh_num; i++) {