[net.unix-wizards] Sign bit smeared in TIOCLGET

mike%brl-vgr@sri-unix.UUCP (12/16/83)

From:      Michael John Muuss <mike@brl-vgr>

Index:	sys/sys/tty.c 4.2BSD

Description:
	If the high bit of the "local flags" is set, TIOCLGET smears
	that bit across the high halfword of the int by the >>16.
	Credit for finding this goes to Doug Gwyn, <Gwyn@BRL>.
Repeat-By:
	Set the bit with TIOCLSET, and read it back with TIOCLGET.
Fix:
	Mask the data.  See diff -c listing below.

*** tty.c~	Thu Dec 15 19:47:12 1983
--- tty.c	Thu Dec 15 19:48:14 1983
***************
  		break;
  
  	case TIOCLGET:
! 		*(int *)data = tp->t_flags >> 16;
  		break;
  
  	/* should allow SPGRP and GPGRP only if tty open for reading */

--------------
  		break;
  
  	case TIOCLGET:
! 		*(int *)data = (tp->t_flags >> 16) & 0xFFFF;
  		break;
  
  	/* should allow SPGRP and GPGRP only if tty open for reading */