Question: The following program, written in C, writes data all over the data section, starting from the local variable i. Compile and run the program, then

The following program, written in C, writes data all
over the data section, starting from the local variable i. Compile and
run the program, then answer the questions. Note that the results vary
with different compilers and operating systems, so specify the systems
you used.
Note the behavior of the while loop. The first statement in the loop
(*j=0;) writes a zero to the RAM address stored in variable j. The
second statement (j=j-1;) moves the address downward in RAM each
time the loop executes. Each step of j moves by a short integer,
which is 2 bytes (16 bits) long.
main() {
short i, *j;
j = &i;
while(1) {
*j = 0;
j = j-1;
}
}
(a) Describe what happens when the program runs.
(b)Does the program behave differently if we store a nonzero value in
the first statement in the while loop? For example, substitute 21845
(in hex, 0x5555, alternating 0s and 1s). Describe what happens.
Try another numerical value and describe what happens.
(c) Does the program behave differently if we add 1 instead of
subtracting 1 in the second statement? Try it while storing zeros
and find out. Describe what happens.
(d)Repeat part (c), but use a nonzero value as described in part (b).
(e) Write a program that reads text into an input buffer that is 10 bytes
long. Run the program and type in 20 bytes. What happens? Do you get a different result if you use a different language, for
example, C versus Java?
(f) Look up information about the Morris worm. Identify other
vulnerabilities that the worm used to propagate.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!