summaryrefslogtreecommitdiffstats
path: root/login.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-05-30 13:12:46 +1000
committerDamien Miller <djm@mindrot.org>2000-05-30 13:12:46 +1000
commitc252e2efa1d5171d8cd8c4d452c30f7e86ed2360 (patch)
tree675490abbf7ee02a0eb319ef181655a3ef6cb129 /login.c
parentbe260a0f0d08d471c1065effb37f85f632e493ac (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.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/login.c b/login.c
index 49853bdc..6749a155 100644
--- a/login.c
+++ b/login.c
@@ -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) {