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