Skip to content

Instantly share code, notes, and snippets.

@Cee
Created July 31, 2014 15:34
Show Gist options
  • Save Cee/f4cc0270a4c57aa036b3 to your computer and use it in GitHub Desktop.
Save Cee/f4cc0270a4c57aa036b3 to your computer and use it in GitHub Desktop.
Test
void test() {
volatile unsigned long long val;
volatile unsigned long long local = 0xdeadbeef;
char* variable_length;
entry_check(3); /* Make sure entered this function properly */
val = getbuf();
if (val <= 40) {
variable_length = alloca(val);
}
entry_check(3);
/* Check for corrupted stack */
if (local != 0xdeadbeef) {
printf("Sabotaged!: the stack has been corrupted\n");
}
else if (val == cookie) {
printf("Boom!: getbuf returned 0x%llx\n", val);
if (local != 0xdeadbeef) {
printf("Sabotaged!: the stack has been corrupted\n");
}
if (val != cookie) {
printf("Sabotaged!: control flow has been disrupted\n");
}
validate(3);
} else {
printf("Dud: getbuf returned 0x%llx\n", val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment