Skip to content

Commit

Permalink
macho: fix possible integer overflow when calc atom and lsda offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Dec 3, 2023
1 parent f9c4ba5 commit 2374e48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MachO/Object.zig
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ fn initUnwindRecords(self: *Object, sect_id: u8, macho_file: *MachO) !void {
.local => {
out.atom = self.findAtom(rec.rangeStart);
const atom = out.getAtom(macho_file);
out.atom_offset = @intCast(atom.getInputAddress(macho_file) - rec.rangeStart);
out.atom_offset = @intCast(rec.rangeStart - atom.getInputAddress(macho_file));
},
},
16 => { // personality function
Expand All @@ -555,7 +555,7 @@ fn initUnwindRecords(self: *Object, sect_id: u8, macho_file: *MachO) !void {
.local => {
out.lsda = self.findAtom(rec.lsda);
const atom = out.getLsdaAtom(macho_file).?;
out.lsda_offset = @intCast(atom.getInputAddress(macho_file) - rec.lsda);
out.lsda_offset = @intCast(rec.lsda - atom.getInputAddress(macho_file));
},
},
else => {},
Expand Down

0 comments on commit 2374e48

Please sign in to comment.