This is in response to CodeQL security scan alerts 1-3.
Elf[32|64]_Ehdr[.e_phnum|.e_phentsize|.e_shnum|.e_shentsize] are all uint16_t. This means the loop-var i is bounded by uint16_t and should fit in a uint32_t (to prevent unsigned overflow in the loop). A switch to unsigned still makes sense because we reduce the future chance of unnecessary signed overflow (=UB) in the loop body.
All program/section-header table entry sizes are cast to uin64_t even though the multiplication is bound to uint32_t by both factors bound by uint16_t. This fixes the potential overflow before conversion to the bigger type.
This is in response to CodeQL security scan alerts 1-3.
Elf[32|64]_Ehdr[.e_phnum|.e_phentsize|.e_shnum|.e_shentsize]
are alluint16_t
. This means the loop-vari
is bounded byuint16_t
and should fit in auint32_t
(to prevent unsigned overflow in the loop). A switch to unsigned still makes sense because we reduce the future chance of unnecessary signed overflow (=UB) in the loop body.All program/section-header table entry sizes are cast to
uin64_t
even though the multiplication is bound touint32_t
by both factors bound byuint16_t
. This fixes the potential overflow before conversion to the bigger type.skip-changelog