检查 ELF 文件是否被截断
Checking if an ELF file is truncated
我正在尝试使用 elf 信息获取文件的大小,以检查文件是否未被截断。
我现在正在做的是将使用 lseek(fd, 0, SEEK_END)
的文件大小与 (all sections + elf->e_ehsize + (elf->e_phnum * elf->e_phentsize) + (elf->e_shnum * elf->e_shentsize))
的大小进行比较,但这似乎不正确。你们知道如何知道 elf 文件是否被截断了吗?
编辑:我只允许使用 glibc
I am dooing right now is comparing the size of the file ... with the size of (all sections + elf->e_ehsize + (elf->e_phnum * elf->e_phentsize) + (elf->e_shnum * elf->e_shentsize))
but, this doesn't seem correct.
您可能忽略了部分对齐。除了sh_size
.
之外还需要注意sh_offset
我正在尝试使用 elf 信息获取文件的大小,以检查文件是否未被截断。
我现在正在做的是将使用 lseek(fd, 0, SEEK_END)
的文件大小与 (all sections + elf->e_ehsize + (elf->e_phnum * elf->e_phentsize) + (elf->e_shnum * elf->e_shentsize))
的大小进行比较,但这似乎不正确。你们知道如何知道 elf 文件是否被截断了吗?
编辑:我只允许使用 glibc
I am dooing right now is comparing the size of the file ... with the size of
(all sections + elf->e_ehsize + (elf->e_phnum * elf->e_phentsize) + (elf->e_shnum * elf->e_shentsize))
but, this doesn't seem correct.
您可能忽略了部分对齐。除了sh_size
.
sh_offset