diff options
author | pst <pst@FreeBSD.org> | 1997-01-07 19:00:52 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1997-01-07 19:00:52 +0000 |
commit | bc821ff35736498a1f5fbea36d9d0e7f94d53900 (patch) | |
tree | 8a07ae32e6d529f41b05f497daa2b3bf4fc0150d /libexec | |
parent | 4dfbc233a2bd38ba2bbaf687fa8bbc27d8b09782 (diff) | |
download | FreeBSD-src-bc821ff35736498a1f5fbea36d9d0e7f94d53900.zip FreeBSD-src-bc821ff35736498a1f5fbea36d9d0e7f94d53900.tar.gz |
Some buffer overrun fixes and removed check for username starting with "-"
(replacied it with a getopt stopper (--) instead, which is more correct).
Obtained from: OpenBSD
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/telnetd/sys_term.c | 12 | ||||
-rw-r--r-- | libexec/telnetd/telnetd.c | 14 | ||||
-rw-r--r-- | libexec/telnetd/utility.c | 3 |
3 files changed, 16 insertions, 13 deletions
diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c index 72a1ff3..8bbe3fe 100644 --- a/libexec/telnetd/sys_term.c +++ b/libexec/telnetd/sys_term.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: sys_term.c,v 1.14 1996/09/22 21:55:42 wosch Exp $ */ #ifndef lint @@ -1624,6 +1624,7 @@ start_login(host, autologin, name) if (auth_level >= 0 && autologin == AUTH_VALID) { # if !defined(NO_LOGIN_F) argv = addarg(argv, "-f"); + argv = addarg(argv, "--"); argv = addarg(argv, name); # else # if defined(LOGIN_R) @@ -1696,17 +1697,14 @@ start_login(host, autologin, name) pty = xpty; } # else + argv = addarg(argv, "--"); argv = addarg(argv, name); # endif # endif } else #endif - if (user = getenv("USER")) { - if (strchr(user, '-')) { - syslog(LOG_ERR, "tried to pass user \"%s\" to login", - user); - fatal(net, "invalid user"); - } + if (getenv("USER")) { + argv = addarg(argv, "--"); argv = addarg(argv, getenv("USER")); #if defined(LOGIN_ARGS) && defined(NO_LOGIN_P) { diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c index afbced3..1c57eb0 100644 --- a/libexec/telnetd/telnetd.c +++ b/libexec/telnetd/telnetd.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: telnetd.c,v 1.7 1996/09/22 21:55:46 wosch Exp $ */ #ifndef lint @@ -668,12 +668,14 @@ getterminaltype(name) * we have to just go with what we (might) have already gotten. */ if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) { - (void) strncpy(first, terminaltype, sizeof(first)); + (void) strncpy(first, terminaltype, sizeof(first)-1); + first[sizeof(first)-1] = '\0'; for(;;) { /* * Save the unknown name, and request the next name. */ - (void) strncpy(last, terminaltype, sizeof(last)); + (void) strncpy(last, terminaltype, sizeof(last)-1); + last[sizeof(last)-1] = '\0'; _gettermname(); if (terminaltypeok(terminaltype)) break; @@ -691,8 +693,10 @@ getterminaltype(name) * the start of the list. */ _gettermname(); - if (strncmp(first, terminaltype, sizeof(first)) != 0) - (void) strncpy(terminaltype, first, sizeof(first)); + if (strncmp(first, terminaltype, sizeof(first)) != 0) { + (void) strncpy(terminaltype, first, sizeof(terminaltype)-1); + terminaltype[sizeof(terminaltype)-1] = '\0'; + } break; } } diff --git a/libexec/telnetd/utility.c b/libexec/telnetd/utility.c index 3620813..6786bba 100644 --- a/libexec/telnetd/utility.c +++ b/libexec/telnetd/utility.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: utility.c,v 1.5 1996/09/22 21:55:52 wosch Exp $ */ #ifndef lint @@ -98,6 +98,7 @@ stilloob(s) do { FD_ZERO(&excepts); FD_SET(s, &excepts); + memset((char *)&timeout, 0, sizeof timeout); value = select(s+1, (fd_set *)0, (fd_set *)0, &excepts, &timeout); } while ((value == -1) && (errno == EINTR)); |