Subject: Re: lib/2948: possible buffer overflow in ttyaction
To: None <netbsd-bugs@NetBSD.ORG>
From: Christoph Badura <bad@flatlin.ka.sub.org>
List: netbsd-bugs
Date: 11/20/1996 04:09:00
enami@ba2.so-net.or.jp writes:
> /* Environment needs: TTY, ACT, USER */
>- sprintf(env_tty, "TTY=%.63s", tty);
>- sprintf(env_act, "ACT=%.63s", act);
>- sprintf(env_user, "USER=%.255s", user);
>+ sprintf(env_tty, "TTY=%.*s", sizeof(env_tty) - sizeof("TTY="), tty);
>+ sprintf(env_act, "ACT=%.*s", sizeof(env_act) - sizeof("ACT="), act);
>+ sprintf(env_user, "USER=%.*s", sizeof(env_user) - sizeof("USER="),
>+ user);
Better yet, use snprintf.
--
Christoph Badura bad@flatlin.ka.sub.org
You don't need to quote my .signature. Everyone has seen it by now.
Besides, it doesn't add anything to the current thread.