[v2] sprof: check pread size and offset for overflow
DJ Delorie
dj@redhat.com
Fri Oct 17 18:33:53 GMT 2025
Collin Funk <collin.funk1@gmail.com> writes:
> I think that we should check for overflows in this case. I could
> construct an ELF file where the following expression overflows:
>
> (ehdr->e_shnum * sizeof (ElfW (Shdr)) + ehdr->e_shoff
I would check for this with something like:
if (ehdr->e_shnum > filesize / sizeof (ElfW (Shdr)))
error ("too many section numbers")
The above won't overflow, and reports the problem directly.
More information about the Libc-alpha
mailing list