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
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; }
#include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started