Created
July 11, 2015 12:27
-
-
Save mk270/6d441ca4d609f48c1261 to your computer and use it in GitHub Desktop.
This file contains 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> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <string.h> | |
int main(int argc, char *argv[], char *env[]) { | |
char *arena; | |
char hex[100]; | |
char *target; | |
arena = malloc(1024); | |
strcpy(arena, "Hello world.\n"); | |
sprintf(hex, "%lx\n", (intptr_t) arena); | |
/* in the real world example, the monstrosity in hex is passed to | |
a different function which has responsibility for sscanf()ing and | |
free()ing it */ | |
sscanf(hex, "%lx", (intptr_t *) &target); | |
printf("%p\n%s\n", target, target); | |
free(target); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment