Skip to content

Commit

Permalink
fix(COFF): incorrect off-by-one extended relocation count
Browse files Browse the repository at this point in the history
  • Loading branch information
boricj committed Aug 17, 2024
1 parent 1486064 commit f47c58c
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,21 @@ public short headerCount() {
return (short) relocations.size();
}

private int extendedCount() {
if (linkOverflow()) {
return relocations.size() + 1;
}
return relocations.size();
}

public int size() {
return (linkOverflow() ? RECORD_SIZE : 0) + (relocations.size() * RECORD_SIZE);
return extendedCount() * RECORD_SIZE;
}

public void write(DataOutput out, DataConverter dc) throws IOException {
byte[] record = new byte[RECORD_SIZE];
if (linkOverflow()) {
dc.putInt(record, 0, relocations.size());
dc.putInt(record, 0, extendedCount());
dc.putInt(record, 4, 0);
dc.putShort(record, 8, (short) 0);
out.write(record);
Expand Down

0 comments on commit f47c58c

Please sign in to comment.