Skip to content

Instantly share code, notes, and snippets.

@technion
Created October 22, 2014 11:10
Show Gist options
  • Save technion/e247be27f8c9dbf26c7e to your computer and use it in GitHub Desktop.
Save technion/e247be27f8c9dbf26c7e to your computer and use it in GitHub Desktop.
#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