Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the program below: #include <stdio.h> #include <string.h> void foo(int a,

ID: 3894447 • Letter: G

Question

Given the program below:

#include <stdio.h>

#include <string.h>

void foo(int a, int b, int c)

{

   int tmp;

   a=2;

   tmp = b+c*a;

} <----------

int main(int argc, char * argv[])

{

    int pass = 0;   

    char buff[15];

foo(3,4,5);

printf(" Enter the password : ");

    gets(buff);

    if(strcmp(buff, "testpilot"))

    {

        printf (" Wrong Password ");

    }

    else

    {

        printf (" Correct Password ");

        pass = 1;

    }

if(pass)

    {

       /* Now Give root or admin rights to user*/

        printf (" Root privileges given to the user ");

    }

return 0;

}

Assume the program is in a file called: test.c

It is compiled and linked using gcc test. c –a test

and is executed as ./test

The activation records up to where the arrow indicates:

Parameter -> right-to-left       local variables -> top-to-bottom       word size is 32 bits


Show what input, other than testpilot will give root privileges. _______________

Explanation / Answer

1.

    temp
    ----
      a
    ----
      b
     ---
      c  

   c,b,a,temp occupy 4 boxes (4 bytes) each


There is no other input than testpilot will give the root previlages

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote