Or not. This is just a question I want to see if anybody can answer.
The following code alters data, I want someone to tell me why it does this, and
what the name of this kind of program exploit is called. This program won't die of segmentation fault either, so you can't say "It'll die of segmentation violation."
Code is as follows:
#include <stdio.h>
#include <malloc.h>
int main() {
char *buf1=(char *)malloc(16),*buf2=(char *)malloc(16);
memset(buf2,'A',15);
printf("Before: %s\n",buf2);
memset(buf1,'B',23);
printf("After: %s",buf2);
getchar();
return 0;
}
First one to tell me, and get the right answer gets a prize.
Prize: [undecided]