| ... | @@ -801,11 +801,9 @@ pub fn abiAndDynamicLinkerFromFile( | ... | @@ -801,11 +801,9 @@ pub fn abiAndDynamicLinkerFromFile( |
| 801 | | 801 | |
| 802 | if (dynstr) |ds| { | 802 | if (dynstr) |ds| { |
| 803 | if (rpath_offset) |rpoff| { | 803 | if (rpath_offset) |rpoff| { |
| 804 | // TODO this pointer cast should not be necessary | 804 | if (rpoff > ds.size) return error.InvalidElfFile; |
| 805 | const rpoff_usize = std.math.cast(usize, rpoff) orelse return error.InvalidElfFile; | 805 | const rpoff_file = ds.offset + rpoff; |
| 806 | if (rpoff_usize > ds.size) return error.InvalidElfFile; | 806 | const rp_max_size = ds.size - rpoff; |
| 807 | const rpoff_file = ds.offset + rpoff_usize; | | |
| 808 | const rp_max_size = ds.size - rpoff_usize; | | |
| 809 | | 807 | |
| 810 | const strtab_len = @min(rp_max_size, strtab_buf.len); | 808 | const strtab_len = @min(rp_max_size, strtab_buf.len); |
| 811 | const strtab_read_len = try preadMin(file, &strtab_buf, rpoff_file, strtab_len); | 809 | const strtab_read_len = try preadMin(file, &strtab_buf, rpoff_file, strtab_len); |