Subject: lib/28183: getttyent(3) broken
To: None <,,>
From: None <>
List: netbsd-bugs
Date: 11/10/2004 22:55:01
>Number:         28183
>Category:       lib
>Synopsis:       getttyent(3) broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 10 22:55:00 +0000 2004
>Originator:     Brian Marcotte
>Release:        NetBSD 2.0_RC4
System: NetBSD 2.0_RC4 NetBSD 2.0_RC4 (PANIX-USER) #0: Sat Nov 6 19:39:39 EST 2004 i386
	Userland matches kernel
Architecture: i386
Machine: i386

In some cases, the library function "getttyent" does not set "ty_type"
correctly. This causes TERM to be set incorrectly in the cases where
TERM is set from /etc/ttys.

If the appropriate line in /etc/ttys has no flags like this one:

   ttyp0   none                            vt100

then getttyent will fill in ty_type with "vt10".

Since this function is used by "login" and others, users wind up
with TERM set to "vt10".


Using a stock /etc/ttys file, this will show the problem:

#include <ttyent.h>
#include <stdio.h>
#include <stdlib.h>

int main()
  struct ttyent *t;

  t = getttynam("ttyp0");

  if (t==NULL) {
    printf("t: NULL\n");
  printf("t->ty_type: %s\n",t->ty_type);

It should print "t->ty_type: networ".


I'm not entirely sure, but it looks like the bug is in the "skip" function
in src/lib/libc/gen/getttyent.c.

- Brian