Created
October 22, 2014 11:10
-
-
Save technion/e247be27f8c9dbf26c7e to your computer and use it in GitHub Desktop.
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> | |
#include <string.h> | |
#include <stdlib.h> | |
void not_vulnerable(char *s) { | |
char buf[1024]; | |
int size = sizeof s; | |
printf("Detected size was %d\n", size); | |
if (size > 1024) { | |
exit(1); | |
} | |
else { | |
strcpy(buf, s); | |
} | |
} | |
void do_crash() { | |
char buf[2048]; | |
memset(buf, 'a', 2046); | |
buf[2047] = '\0'; | |
not_vulnerable(buf); | |
} | |
int main() { | |
do_crash(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment