Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Evaluate the integral. (1 + tan x) 2 sec x dx

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago