summaryrefslogtreecommitdiff
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 49853bdc2..6749a1556 100644
--- a/login.c
+++ b/login.c
@@ -18,7 +18,7 @@
18 */ 18 */
19 19
20#include "includes.h" 20#include "includes.h"
21RCSID("$Id: login.c,v 1.27 2000/05/17 12:00:03 damien Exp $"); 21RCSID("$Id: login.c,v 1.28 2000/05/30 03:12:46 damien Exp $");
22 22
23#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) 23#if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
24# include <utmpx.h> 24# include <utmpx.h>
@@ -217,10 +217,13 @@ record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid,
217# ifdef HAVE_HOST_IN_UTMPX 217# ifdef HAVE_HOST_IN_UTMPX
218# ifdef HAVE_SYSLEN_IN_UTMPX 218# ifdef HAVE_SYSLEN_IN_UTMPX
219 utx.ut_syslen = strlen(host); 219 utx.ut_syslen = strlen(host);
220 if (utx.ut_syslen + 1 > sizeof(utx.ut_host))
221 utx.ut_syslen = sizeof(utx.ut_host);
220 strncpy(utx.ut_host, host, utx.ut_syslen); 222 strncpy(utx.ut_host, host, utx.ut_syslen);
221# else 223# else
222 strncpy(utx.ut_host, host, sizeof(utx.ut_host)); 224 strncpy(utx.ut_host, host, sizeof(utx.ut_host));
223# endif /* HAVE_SYSLEN_IN_UTMPX */ 225# endif /* HAVE_SYSLEN_IN_UTMPX */
226 utx.ut_host[sizeof(utx.ut_host)-1] = '\0';
224# endif 227# endif
225#if defined(HAVE_ADDR_IN_UTMPX) 228#if defined(HAVE_ADDR_IN_UTMPX)
226 if (addr) { 229 if (addr) {