Tag: security

Questions Related to security

Are there any memory issues in the following code? Please assume that variable inputsize has the correct size.

int add_num_array(int inputsize, int num) {
    int *newnum = malloc (inputsize * sizeof(int));  /* 1 */
    int i;   
    for (i=0; i
  1. No vulnerabilities are present

  2. Line 1 should only use malloc(inputsize);

  3. Line 2 should be for (i=0; i<=n, i++)

  4. Line 1 should use calloc() instead of malloc()


Correct Option: D

What is the vulnerability in this code?

    char output[20];  
    /*   Assume data is a character array with value %200d asdf   */  
    sprintf(output, data);
  1. Buffer overflow

  2. Off by one error

  3. Format string vulnerability

  4. No vulnerabilities are present in this code


Correct Option: C
  1. Buffer overflow

  2. Off by one error

  3. Format string vulnerability

  4. No vulnerabilities are present in this code


Correct Option: C
  1. /GS on Visual C++ and -fmudflap -fmudflapth -fmudflapir on GCC

  2. /O in Vc++ and -O2 in GCC

  3. /S in Vc++ and -fcrossjumping in GCC

  4. /S in VC++ and -fno-function-cse in GCC


Correct Option: A

Which compilation switch should be enabled for stack protection? Choose the best and most secure option.

  1. fstack-protector

  2. fstack-protector-all

  3. fdelete-null-pointer-checks

  4. Both a and b


Correct Option: B