Commit a83710e5 authored by Petr Stetiar's avatar Petr Stetiar Committed by Sam Ravnborg

kbuild: fix segfault in modpost

Fix modpost segfault.

Before:
-------
ynezz@ntbk:~/linux-2.6.git$ scripts/mod/modpost vmlinux ath_pci.o
Segmentation fault

After:
------
ynezz@ntbk:~/linux-2.6.git$ scripts/mod/modpost vmlinux ath_pci.o
FATAL: section header offset=815726848 in file 'ath_pci.o' is bigger then filesize=153968

Sam: This seems to warn for a binutils issue. Anyway modpost should not
segfault.
Signed-off-by: default avatarPetr Stetiar <ynezz@true.cz>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 88f567f3
...@@ -381,6 +381,12 @@ static int parse_elf(struct elf_info *info, const char *filename) ...@@ -381,6 +381,12 @@ static int parse_elf(struct elf_info *info, const char *filename)
sechdrs = (void *)hdr + hdr->e_shoff; sechdrs = (void *)hdr + hdr->e_shoff;
info->sechdrs = sechdrs; info->sechdrs = sechdrs;
/* Check if file offset is correct */
if (hdr->e_shoff > info->size) {
fatal("section header offset=%u in file '%s' is bigger then filesize=%lu\n", hdr->e_shoff, filename, info->size);
return 0;
}
/* Fix endianness in section headers */ /* Fix endianness in section headers */
for (i = 0; i < hdr->e_shnum; i++) { for (i = 0; i < hdr->e_shnum; i++) {
sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment