Skip to content
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

10 = 666; considered legal #72

Open
tommythorn opened this issue Sep 5, 2022 · 0 comments
Open

10 = 666; considered legal #72

tommythorn opened this issue Sep 5, 2022 · 0 comments

Comments

@tommythorn
Copy link

I cut my teeth on Small-C eons ago and c4 is an absolute delight and very clever. However, I did think the lvalue trick looked too fragile and indeed, if you generate just the right constant, like 9 or 10, you can trick it.

int main(int argc, char **argv) {
    10 = 666;
}

This compiles and will lead to stack corruption.

Definitely not hard to fix and probably not worthwhile.

tommythorn added a commit to tommythorn/c4 that referenced this issue Sep 10, 2022
When checking if the last generated instruction was a load, we have to
protected against all the other things that can look like a load.
Since we only ever care about the most recently generated load and we
always overwrite with another opcode it suffice to trace the address
of the most recently generated load.
tommythorn added a commit to tommythorn/c4 that referenced this issue Sep 15, 2023
When checking if the last generated instruction was a load, we have to
protected against all the other things that can look like a load.
Since we only ever care about the most recently generated load and we
always overwrite with another opcode it suffice to trace the address
of the most recently generated load.
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

No branches or pull requests

1 participant