Last active
January 13, 2022 13:49
-
-
Save lightdiscord/b51b1b23efb057414aad5eb48fd13046 to your computer and use it in GitHub Desktop.
Use bytes stored near other when pointer points to a bigger type.
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
$ clang -Wall -Wextra -g3 ./main.c -o main && ./main | |
deadbeef |
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
#include <stdio.h> | |
void fn(int *ptr) { | |
printf("%x\n", *ptr); | |
} | |
int main() { | |
short a = 0xdead; | |
short b = 0xbeef; | |
(void)a; | |
fn((int*)&b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment