Due date: January 18, 2006
Text, problem 1.1.
Text, problem 1.3.
Text, problem 1.7.
Text, problem 1.14.
Handout, exercise 2.
Consider the Linux system call
. It changes the position of
the offset of the file descriptor, so reading or writing after the
call begins at the position indicated by the second and third
arguments to lseek.
On success, the function returns the new offset. On failure, it returns -1.
But -1 is also a valid offset, representing a position of
0xffffffff. The manual page suggests using errno
to distinguish between success and failure.
how to do this, and
give sample code.
This exercise asks you to look at the standard
I/O library for problems with robustness. Please write two programs that
use functions from the strings library (the functions in that
library are listed in the stdio(3)
manual page on the Linux CSIF systems). You are to call the
functions in such a way that they cause the library function to crash.
To show that your program crashes the standard I/O function, use
output to show that the crash
occured within the library function. That is,
the program must call the standard I/O library function,
but cannot return from that call.
Please explain why the library function fails.
Support your hypothesis with references to the gdb
output (or to source code, if that is available—but state
how you know your version of the source code is the version
Important note: you must supply the correct type of argument
for the functions. You may not, for example, pass a character
pointer where a file pointer is expected.
Your two programs must not use the same technique to cause the crashes.
For example, if you discover a certain argument to
causes a crash, you cannot
use that same argument to cause a crash in
. However, if a
different argument will cause fwrite(3)
feel free to use that.
Version of January 4, 2006 at 1:49 PM
You can also obtain a PDF version of this.