Question: This is a c code #include #include int main(void) { char buff[15]; char sysCommand[10]; char extra[2]; char *charPtr = malloc(15 * sizeof(*charPtr)); int pass; extra[2]

This is a c code

#include

#include

int main(void)

{

char buff[15];

char sysCommand[10];

char extra[2];

char *charPtr = malloc(15 * sizeof(*charPtr));

int pass;

extra[2] = '\0';

printf(" Enter the password : ");

gets(buff);

if(strcmp(buff, "Joshua") == 0)

{

pass = 2;

}

else if (strcmp(buff, "Student123") == 0)

{

printf (" Correct Password. You may do an ls or whoami ");

pass = 1;

}

if(pass == 1)

{

printf ("Command: ");

gets(sysCommand);

if (strcmp(sysCommand, "ls") == 0 || strcmp(sysCommand, "whoami") )

system(sysCommand);

}

else if (pass == 2)

{

printf("Greetings Professor Falken ");

printf("Command: ");

gets(sysCommand);

system(sysCommand);

}

return 0;

}

List 5 potential security issues with the code (and there are lots of things wrong)

And fix this code if you can.

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!