[1610] in Athena Bugs
fseek to a negative locations does not give an error (VS 60R)
daemon@ATHENA.MIT.EDU (Theodore Ts'o)
Sat Jan 7 03:18:40 1989
Date: Sat, 7 Jan 89 03:17:33 EST
From: Theodore Ts'o <tytso@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
Reply-To: tytso@ATHENA.MIT.EDU
Repeat by:
Entering saber:
FILE *foo;
foo = fopen("/etc/passwd", r);
fseek(foo, -12, 0); <=== Attempt to seek -12 bytes
from the start of the file
(note that the return status is 0, signfying everything is
ok. Hah!)
According to the man page for fseek, it is supposed to return -1 for
improper seeks. Seeking to before the beginning of the file certainly
seems to be improper! If a fread is attempted, it will fail; but the
fseek should not have returned 0 in the first place.
- Ted