Question: a) Examine the create_person function. This function has a problem which might lead to unexpected behavior. What is it? b) Now consider the main function.

 a) Examine the create_person function. This function has a problem which

a) Examine the create_person function. This function has a problem which might lead to unexpected behavior. What is it?

b) Now consider the main function. What potential security issues exist in this function? excluding its effects from create_person function

c) What might you do to fix the potential security issue in main?

Consider the following C code which has several memory-related problems (but compiles #include #include struct person { char* name: }; struct person* create_person (char* name) { struct person newperson = {name}; return anewperson; } int main() { char *str = malloc(sizeof (char) -10); printf ("Enter a name: "); scanf("%s", str); if (str) { struct person pl = create_person (str); printf ("Your person's name: \"}3\" ", p1->name); free (str); } 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!