Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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; }

image text in transcribed

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

what are the provisions in the absence of Partnership Deed?

Answered: 1 week ago

Question

1. What is called precipitation?

Answered: 1 week ago

Question

1.what is dew ?

Answered: 1 week ago

Question

7. What is coaching? Is there only one type of coaching? Explain.

Answered: 1 week ago