Here are the steps to make a program that will lead to a buffer overflow:
- Define a structure consisting of two members, name and orderid.
- Define two variables of the structure type defined in step 1. In one of the structure variables, we will deliberately generate a buffer overflow by entering a large amount of data.
- Prompt the user to enter a value for the orderid member for the first structure.
- Invoke the fpurge function to empty out the input stream buffer before invoking the gets function.
- Invoke the gets function to enter data for the name member for the first structure. Enter text that is larger than the length of the name member.
- Repeat steps 3 to 5 to enter data for the orderid and name members for the second structure. ...