Subject: bin/45: talk(1) core dumps with no TERM set
To: None <gnats-admin>
From: None <tholo@SigmaSoft.COM>
List: netbsd-bugs
Date: 12/15/1993 17:05:03
>Number:         45
>Category:       bin
>Synopsis:       If no TERM env. var is set, talk(1) core dumps on startup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 15 17:05:02 1993
>Originator:     Thorsten Lockert
>Organization:
Thorsten Lockert  | postmaster@bbb.no   |
Postbox 435       | hostmaster@bbb.no   |  Universe, n.:
N-5001 Bergen     | tholo@bbb.no        |          The problem.
Norway            | tholo@sigmasoft.com |
>Release:        0.9-current
>Environment:
System: NetBSD gandalf.bbb.no 0.9a GANDALF#10 i386
>Description:
It you do not have a terminal set, or your terminal is not powerful enough
to support curses(3), talk will coredump when started as it does not check
the return value from initscr(3curses).  The following patch fixes this and
a comparison problem in init_disp.c
>How-To-Repeat:
TERM= talk username
>Fix:
*** src/usr.bin/talk/init_disp.c.orig	Thu Dec 16 01:29:59 1993
--- src/usr.bin/talk/init_disp.c	Thu Dec 16 01:34:57 1993
***************
*** 54,60 ****
  	void sig_sent();
  	struct sigvec sigv;
  
! 	initscr();
  	(void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv);
  	sigv.sv_mask |= sigmask(SIGALRM);
  	(void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0);
--- 54,63 ----
  	void sig_sent();
  	struct sigvec sigv;
  
! 	if (initscr() == (WINDOW *)NULL) {
! 		printf("Terminal not set or not suitable for use with talk\n");
! 		exit(-1);
! 	}
  	(void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv);
  	sigv.sv_mask |= sigmask(SIGALRM);
  	(void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0);
***************
*** 100,106 ****
  	tcgetattr(0, &tty);
  	my_win.cerase = tty.c_cc[VERASE];
  	my_win.kill = tty.c_cc[VKILL];
! 	if (tty.c_cc[VWERASE] == (char) -1)
  		my_win.werase = '\027';	 /* control W */
  	else
  		my_win.werase = tty.c_cc[VWERASE];
--- 103,109 ----
  	tcgetattr(0, &tty);
  	my_win.cerase = tty.c_cc[VERASE];
  	my_win.kill = tty.c_cc[VKILL];
! 	if ((char)tty.c_cc[VWERASE] == (char) -1)
  		my_win.werase = '\027';	 /* control W */
  	else
  		my_win.werase = tty.c_cc[VWERASE];

>Audit-Trail:
>Unformatted:

------------------------------------------------------------------------------