-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix integer underflow in Unit.resizeHeader() #25974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
+1
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When a DWARF unit has no previous unit (i.e., it's the first unit
in a section), the code incorrectly calculated `available_len = 0`,
even though there was actually `unit.off` bytes of available space
before the unit.
```zig
const available_len = if (unit.prev.unwrap()) |prev_unit| prev_excess: {
const prev_unit_ptr = sec.getUnit(prev_unit);
break :prev_excess unit.off - prev_unit_ptr.off - prev_unit_ptr.len;
} else 0; // ← BUG: Should be unit.off, not 0
```
Member
|
How is this change related to an integer underflow? |
It's an AI generated PR but this doesn't show the full reasoning why it's an integer underflow either. |
Member
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When a DWARF unit has no previous unit (i.e., it's the first unit in a section), the code incorrectly calculated
available_len = 0, even though there was actuallyunit.offbytes of available space before the unit.