diff options
author | Damien Miller <djm@mindrot.org> | 2000-05-30 13:12:46 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-05-30 13:12:46 +1000 |
commit | c252e2efa1d5171d8cd8c4d452c30f7e86ed2360 (patch) | |
tree | 675490abbf7ee02a0eb319ef181655a3ef6cb129 /login.c | |
parent | be260a0f0d08d471c1065effb37f85f632e493ac (diff) |
- Fix buffer overrun in login.c for systems which use syslen in utmpx.
patch from YOSHIFUJI Hideaki <yoshfuji@cerberus.nemoto.ecei.tohoku.ac.jp>
Diffstat (limited to 'login.c')
-rw-r--r-- | login.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -18,7 +18,7 @@ */ #include "includes.h" -RCSID("$Id: login.c,v 1.27 2000/05/17 12:00:03 damien Exp $"); +RCSID("$Id: login.c,v 1.28 2000/05/30 03:12:46 damien Exp $"); #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) # include <utmpx.h> @@ -217,10 +217,13 @@ record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid, # ifdef HAVE_HOST_IN_UTMPX # ifdef HAVE_SYSLEN_IN_UTMPX utx.ut_syslen = strlen(host); + if (utx.ut_syslen + 1 > sizeof(utx.ut_host)) + utx.ut_syslen = sizeof(utx.ut_host); strncpy(utx.ut_host, host, utx.ut_syslen); # else strncpy(utx.ut_host, host, sizeof(utx.ut_host)); # endif /* HAVE_SYSLEN_IN_UTMPX */ + utx.ut_host[sizeof(utx.ut_host)-1] = '\0'; # endif #if defined(HAVE_ADDR_IN_UTMPX) if (addr) { |