[net.unix] About that "w+" bug in 4.3...

bnfb@uw-june (Bjorn Freeman-Benson) (10/16/86)

A number of people responded to my claim of a bug in 4.3 stdio with "w+".
The mail was like this:
	2 said no such bug no my machine
	2 said yep, bug on my machine
After conversing with someone (* see below) I learned that this was a bug in
the past, but most "normal" 4.3 distributions did not have it.  Here at the
University of Washington we are running a Beta version of 4.3 and so it had
this bug.  If you have this bug there is a rather easy fix, but I don't know
it.

* You see, I accidentally deleted my mailbox/folder were I was keeping this
entire discussion and so I have lost the names and e-mail addresses of those
who helped me, especially the kind fellow who told me about the bug fix.  So,
if you're out there (and I know you are), could you post the fix to this group
so that those who agreed with my bug can also fix their machines?

						Bjorn N Freeman-Benson

donn@utah-cs.UUCP (Donn Seeley) (10/17/86)

Here's some fixes I made to the 4.3 beta fputs().  The first change
solves a problem with _IORW stdio FILEs; the second fixes a problem
with unbuffered FILEs.  The source is in /usr/src/lib/libc/vax/stdio/fputs.c.

------------------------------------------------------------------------
*** /tmp/,RCSt1013008	Mon Oct 13 22:59:50 1986
--- /tmp/,RCSt2013008	Mon Oct 13 22:59:51 1986
***************
*** 64,71 ****
  	jbr	2f
  
  1:
! 	tstl	_BASE(IOP)		/* Has a buffer been allocated? */
! 	jneq	2f
  	pushl	IOP			/* Get _flsbuf() to do the work */
  	pushl	$0
  	calls	$2,__flsbuf
--- 64,71 ----
  	jbr	2f
  
  1:
! 	tstl	_CNT(IOP)		/* Has a buffer been allocated? */
! 	jgtr	2f
  	pushl	IOP			/* Get _flsbuf() to do the work */
  	pushl	$0
  	calls	$2,__flsbuf
***************
*** 90,95 ****
--- 90,97 ----
  	movl	r3,_PTR(IOP)		/* Fix up IOP */
  	subl2	COUNT,_CNT(IOP)
  	bitw	$LBF,_FLAG(IOP)		/* If line buffered... */
+ 	jneq	1f
+ 	tstw	UNBUF			/* or unbuffered... */
  	jneq	1f
  	tstl	_CNT(IOP)		/* or a full buffer... */
  	jgtr	2f
------------------------------------------------------------------------

Equivalent fixes were made to puts.c, too.  This fix should be in the
4.3 BSD release -- if you're not running it, you probably should be.

Donn Seeley    University of Utah CS Dept    donn@utah-cs.arpa
40 46' 6"N 111 50' 34"W    (801) 581-5668    decvax!utah-cs!donn

PS -- There's at least one minor bug in the distributed fputs(), too;
so it goes.