mirror of
https://github.com/ziglang/zig.git
synced 2026-01-01 19:13:16 +00:00
elf: upcast e_shnum to u64 to check for valid ranges
This commit is contained in:
parent
b294103c7e
commit
e349bb2b66
@ -68,7 +68,7 @@ pub fn parse(self: *Object, elf_file: *Elf) !void {
|
||||
const gpa = elf_file.base.allocator;
|
||||
|
||||
if (self.data.len < self.header.?.e_shoff or
|
||||
self.data.len < self.header.?.e_shoff + self.header.?.e_shnum * @sizeOf(elf.Elf64_Shdr))
|
||||
self.data.len < self.header.?.e_shoff + @as(u64, @intCast(self.header.?.e_shnum)) * @sizeOf(elf.Elf64_Shdr))
|
||||
{
|
||||
try elf_file.reportParseError2(
|
||||
self.index,
|
||||
|
||||
@ -63,7 +63,7 @@ pub fn parse(self: *SharedObject, elf_file: *Elf) !void {
|
||||
}
|
||||
|
||||
if (self.data.len < self.header.?.e_shoff or
|
||||
self.data.len < self.header.?.e_shoff + self.header.?.e_shnum * @sizeOf(elf.Elf64_Shdr))
|
||||
self.data.len < self.header.?.e_shoff + @as(u64, @intCast(self.header.?.e_shnum)) * @sizeOf(elf.Elf64_Shdr))
|
||||
{
|
||||
try elf_file.reportParseError2(
|
||||
self.index,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user