Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!mcvax!denise From: denise@mcvax.UUCP Newsgroups: comp.bugs.4bsd Subject: Curses Bug Message-ID: <233@sering.mcvax.cwi.nl> Date: Thu, 26-Mar-87 07:36:24 EST Article-I.D.: sering.233 Posted: Thu Mar 26 07:36:24 1987 Date-Received: Sat, 28-Mar-87 05:47:34 EST Reply-To: denise@sering.UUCP (Denise L. Draper) Distribution: world Organization: CWI, Amsterdam Lines: 72 Index: /usr/src/usr.lib/libcurses/cr_tty.c Description: Curses writes to a pointer that points to the static environment variable TERM. This can cause problems if an exec is then done. Repeat-By: %cat > foo.c #include extern char **environ; main() { char *x; initscr(); endwin(); /* show the values of the environment variables */ /* Note that TERM is now screwed up */ while((x = *environ++) != NULL) printf("%s\n",x); execl("/bin/sh", "sh", "-c", "date", 0); } ^D %cc foo.c -lcurses -ltermcap %setenv TERM h2 # or any other of the two-letter names %a.out The crucial feature is that the variable TERM must be shorter than the 2nd terminal name in the appropriate TERMCAP entry (another bug, I think: the function longname in curses claims to find the long name of the terminal, while in fact it simply finds the 2nd name). Fix: Apply the following diff: *** cr_tty.c.old Thu Mar 26 11:34:22 1987 --- cr_tty.c Thu Mar 26 11:34:54 1987 *************** *** 6,11 **** --- 6,12 ---- #ifndef lint static char sccsid[] = "@(#)cr_tty.c 5.2 (Berkeley) 11/8/85"; + static char sccsid2[] = "@(#)cr_tty.c 1.2 (CWI Mods) 87/03/26"; #endif not lint /* *************** *** 134,141 **** PC = _PC ? _PC[0] : FALSE; aoftspace = _tspace; ! strncpy(ttytype, longname(genbuf, type), sizeof(ttytype) - 1); ! ttytype[sizeof(ttytype) - 1] = '\0'; if (unknown) return ERR; return OK; --- 135,141 ---- PC = _PC ? _PC[0] : FALSE; aoftspace = _tspace; ! longname(genbuf,ttytype); if (unknown) return ERR; return OK; denise denise@cwi.nl