Not checking printf's result causes another news bug

John Gilmore gnu at sun.uucp
Thu Aug 15 14:50:47 AEST 1985


> > The printf() function CAN FAIL and if you don't test for it,
> > Murphy says that it WILL fail, under the worst possible
> > circumstances (e.g., while updating YOUR pay record).
> 
> /usr/lib/news/expire uses fprintf to re-write the active file.  It
> didn't take the time to check the return value, and happened to run
> one night when /usr was full.  Result -- a 0 length active file and
> a great deal of unhappy news software.  printf (and fprintf) DO FAIL!

Furthermore, the code in readnews/vnews that implements the "s"
command (save a message to a file) does not check.  The result is that
a day's worth of [manually] archived net.sources stuff ended up as zero
length files, when my net.sources file system filled up -- with no
error messages at all.  Luckily I noticed the empty files before the
original messages expired.

For the people asking "well what can I do if printf returns an error":
how about printing an error to standard error and stopping?  That's
better than letting the data be thrown away without warning.
(Interactive programs like vnews should, of course, not "stop" but
should print a message and go back to the command interpreter.)



More information about the Net.bugs mailing list