Question: Look very carefully at the code below. Can you identify what kind of problem this program will cause (be specific). Feel free to put the

Look very carefully at the code below. Can you identify what kind of problem this program will cause (be specific). Feel free to put the code in your IDE and see if you can

run it. (It may or may not run). What mediation mechanism(s) could you use to stop this problem from happening?

#include #include

void foo(const char* input)

{ char buf[10]; printf("My stuff looks like: %p %p %p %p %p % p ");

strcpy(buf, input); printf("$s ", buf);

printf("My stuff now looks like: %p %p %p %p %p % p "); }

void bar(void)

{ printf("I have been hacked!!");

}

int main(int argc, char* argv[])

{ printf("Address of foo = %p ", foo); printf("Address of bar = %p ", bar); if (argc != 2)

{ printf("Please supply a string as an argument! ");

return -1; }

foo(argv[1]);

return 0; }

 Look very carefully at the code below. Can you identify what

#include #include void foo(const char* input) char buf[10]; printf("My stuff looks like: %p %p %p %p %p % p "); strcpy(buf, input); printf"$sn", buf); printf("My stuff now looks like: %p %p %pin %p %p % p "); void bar(void) printf("I have been hacked!!"); int main(int argc, char* argvl) printf("Address of foo = %p ", foo); printf("Address of bar = %p ", bar); if (argc != 2) printf Please supply a string as an argument ") return -1; foo(argv[1]) return 0

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!