Tag: security
Questions Related to security
Which statement creates a buffer over flow? #include #include #include int main (int argc, char *argv[]) { int i=0,j=1; char ipstring[80]; for (;i<=3;i++){ cout<
Is there a vulnerability in this code? If yes, which line(s) int main (int argc, char argv[]){ char chararray[3]; int intarray[3]; int i; strncpy(chararray, argv[1], sizeof(chararray) - 1); for (i=0;i<=3;i++){ /*1/ chararray[i]= getchar(); intarray[i]=i*i; /2/ } }
What is the vulnerability ? int main (int argc, char *argv[]){ char k[3]; int i=0,j=1; char buffer[50]; strncpy(buffer, argv[1], sizeof(buffer) - 1); buffer[49]='/0'; unsigned char ch='a'; k[0]=1; do{ i++; k[i]=ch+i; } while(i<3); return 0; }
The options show various uses of strncpy. Choose which use of strncpy is most secure while not wasting storage space at dst? Src is an untrusted input obtained from an external source.
While trying to print an eight character long name, which of the following will introduce a security vulnerability ? printf ("%.8s",name); /* 1 / printf (name); / 2 / printf ("%s",name); / 3 / printf ("%8c", name); / 4 */
Which of the following is a secure way to use scanf?
What will be sizeof(name) return? char *name="32000";