Skip to content

Instantly share code, notes, and snippets.

@lightdiscord
Last active January 13, 2022 13:49
Show Gist options
  • Save lightdiscord/b51b1b23efb057414aad5eb48fd13046 to your computer and use it in GitHub Desktop.
Save lightdiscord/b51b1b23efb057414aad5eb48fd13046 to your computer and use it in GitHub Desktop.
Use bytes stored near other when pointer points to a bigger type.
$ clang -Wall -Wextra -g3 ./main.c -o main && ./main
deadbeef
#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