Question: #include #include #include int foo ( char * str ) { char buffer [ 1 0 0 ] ; / * The following statement has

#include #include #include
int foo(char *str)
{
char buffer[100]; /* The following statement has a buffer overflow problem */
strcpy(buffer, str); return 1;
}
int main(int argc, char **argv)
{
char str[400];
FILE *badfile;
badfile = fopen("badfile","r");
fread(str, sizeof(char),300, badfile);
foo(str);
printf("Returned Properly
");
return 1;
}
In the above given sample code expalin how you would perform a bufferoverflow
attack. Draw a detailed diagram of position of variables placed on the stack.
Finally also explain how canary based protection mechanism can be used as
defense.
 #include #include #include int foo(char *str) { char buffer[100]; /* The

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!