Question: Study the following program and answer the questions. int arrayCopy(int array[], int n) { unsigned char y = n * sizeof(int); int savedarray[y]; for(int i
Study the following program and answer the questions.
int arrayCopy(int array[], int n)
{
unsigned char y = n * sizeof(int);
int savedarray[y];
for(int i = 0; i < n; i++){
savedarray[i] = array[i];
}
return 0;
}
1. Is there any possibility of a buffer overflow in the above program and why? For what value of n the overflow will occur, assuming sizeof(int) = 4 and sizeof(char) = 1 ? [1 point]
2. If there is a buffer overflow, will it be in the Stack or Heap? Explain your answer. [1 point]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
