UNIVERSITY OF WISCONSIN
Computer Sciences Department | ||
CS 639
Spring 2019 |
Barton Miller Elisa Heymann |
|
CS 639 - Exercise 3.1: Buffer Overflow | ||
Due: Thursday, February 14 at the start of class |
String
,
Vector
or
Array
standard template classes,
that enfore bounds checking. Be careful that some access methods for
Vector
and
Array
have bounds checking while other do not.
long
).
Experiment with buffer overflows when the array is allocated on the stack, heap, and when it is a global variable.
Overflow by 1, by 2, and then by 100, 1000 and 10,000. What behavior do you see in each case? Explain why you get each result.
Write a report that includes your code, and summarizes the experimentation carried out, the results, and your conclusions.
#include <stdio.h>
#include <stdlib.h>
int i;
long global[10];
int main (int argc, char *argv[]) {
for (i=0; i<100; i++) {
global[i] = 7;
printf ("global[%d]\n", i);
}
printf ("Done\n");
exit (0);
}
Compile and run this program on one of the Computer Science lab Linux machines. What output do you get from the program? Explain why you get this output?