Skip to content

🍒 [Sanitizers][Darwin] Correct iterating of MachO load commands (#130161) #10473

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

Conversation

wrotki
Copy link

@wrotki wrotki commented Apr 10, 2025

The condition to stop iterating so far was to look for load command cmd field == 0. The iteration would continue past the commands area, and would finally find lc->cmd ==0, if lucky. Or crash with bus error, if out of luck.

Correcting this by limiting the number of iterations to the count specified in mach_header(_64) ncmds field.

rdar://143903403


Co-authored-by: Mariusz Borsa [email protected]
(cherry picked from commit 62a6d63)

…30161)

The condition to stop iterating so far was to look for load command cmd
field == 0. The iteration would continue past the commands area, and
would finally find lc->cmd ==0, if lucky. Or crash with bus error, if
out of luck.

Correcting this by limiting the number of iterations to the count
specified in mach_header(_64) ncmds field.

rdar://143903403

---------

Co-authored-by: Mariusz Borsa <[email protected]>
(cherry picked from commit 62a6d63)
@wrotki wrotki requested a review from a team as a code owner April 10, 2025 22:15
@wrotki wrotki requested a review from thetruestblue April 10, 2025 22:16
@wrotki
Copy link
Author

wrotki commented Apr 10, 2025

@swift-ci test

@cyndyishida cyndyishida merged commit bb511df into swift/release/6.1 Apr 15, 2025
3 checks passed
@cyndyishida cyndyishida deleted the eng/m_borsa/cherry_pick_macho_commands_iterating branch April 15, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants