*BSD News Article 3799


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!bunyip.cc.uq.oz.au!psych!robert
From: robert@psych.psy.uq.oz.au (Robert Dal Santo)
Subject: Bug in /usr/include/sys/tty.h (+ PATCH)
Message-ID: <1992Aug18.061135.3464@psych.psy.uq.oz.au>
Keywords: kernel tty patch
Organization: Psychology Department, University of Queensland
Date: Tue, 18 Aug 1992 06:11:35 GMT
Lines: 47

(Posted for a friend.  I will pass on mail messages.)


I haven't seen this one in any FAQ or unofficial bug list, so here is my
chance at World Fame and Everlasting Immortality...


The bug:

The RB_LEN() macro in /usr/include/sys/tty.h is sometimes out by 1.  In
particular, in the case of a buffer containing a single character at the
very end, RB_LEN() would return 0.  This caused ttread() to block until
a 2nd character was read before delivering them both.  The user would find
RAW mode programs such as vi would occasionally (1 in 1024 keypresses)
get "stuck" requiring a second keypress to bring it to life.


The fix:

*** /tmp/,RCSt1000159	Mon Aug 17 13:05:17 1992
--- tty.h	Thu Aug 13 14:07:03 1992
***************
*** 59,65 ****
  
  #define	RB_LEN(rp) \
  		((rp)->rb_hd <= (rp)->rb_tl ? (rp)->rb_tl - (rp)->rb_hd : \
! 		RBSZ - 1 - ((rp)->rb_hd - (rp)->rb_tl))
  
  #define	RB_CONTIGPUT(rp) \
  		(RB_PRED(rp, (rp)->rb_hd) < (rp)->rb_tl ?  \
--- 59,65 ----
  
  #define	RB_LEN(rp) \
  		((rp)->rb_hd <= (rp)->rb_tl ? (rp)->rb_tl - (rp)->rb_hd : \
! 		RBSZ - ((rp)->rb_hd - (rp)->rb_tl))
  
  #define	RB_CONTIGPUT(rp) \
  		(RB_PRED(rp, (rp)->rb_hd) < (rp)->rb_tl ?  \


The thank-you:

Well done Lynne and William, and all helpers.  My life is changed for the
better!  Similar thanks to those who made NET/2 BSD in the first place.


Stephen McKay  Now safely back in BSD land after 4 savage years with System V.