Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B UNSW 1.0 3/14/84; site qfdts.OZ Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!mulga!munnari!basser!uqcspe!qfdts!phil From: phil@qfdts.OZ (Phil Chadwick) Newsgroups: net.bugs.usg Subject: Re: Bug in USG 5.2 stdio package. Message-ID: <20@qfdts.OZ> Date: Tue, 6-Nov-84 17:36:48 EST Article-I.D.: qfdts.20 Posted: Tue Nov 6 17:36:48 1984 Date-Received: Fri, 9-Nov-84 08:48:42 EST References: <556@asgb.UUCP> Organization: Department of Forestry, Brisbane, Australia Lines: 48 In our release of Sys V r2.0 there were four versions of "printf" containing a bug which directs the output into the bit bucket under some circumstances. The subroutines live in the directory "/usr/src/lib/libc/port/print". They are: fprintf.c version 1.5 ) Our release may well printf.c version 1.5 \ differ from yours. vfprintf.c version 1.1 / Check that the versions vprintf.c version 1.1 ) are the same! These routines all fail under circumstances where: (a) a stream is opened for update, (b) data are read from or written to the stream, (c) an fseek() is issued, (d) one of the above *printf() routines is used to write a small amount of data to the stream (i.e. less than a buffer full), (e) the stream is fflush()'d. The cause of the problem appears to be due to a failure of the printf routines to reset the _cnt field of the appropriate FILE structure from zero to the size of the buffer being used prior to writing to the stream. I applied the following fixes to fprintf.c, printf.c, vfprintf.c and vprintf.c some time ago and have had no further problems: (a) Insert "#include ../stdio/stdiom.h" in each file. (b) For fprintf.c and vfprintf.c replace the first compound if statement with: if(_WRTCHK(iop) != 0) return EOF; (c) For printf.c and vprintf.c replace the first compound if statement with: if(_WRTCHK(stdout) != 0) return EOF; ---- Phil Chadwick Australia: (07) 2296500 Department of Forestry International: +61 7 2296500 PO Box 5 Brisbane, Roma Street SUN: phil:qfdts AUSTRALIA 4001 UUCP: {decvax,vax135}!mulga!phil:qfdts