From d89c24b57edf335a69ba20421e2fe52b5f817d19 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 26 Jan 2000 11:04:48 +1100 Subject: - Fix NULL pointer dereference in login.c. Fix from Andre Lucas --- ChangeLog | 4 ++++ login.c | 58 +++++++++++++++++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25f1d3ec6..f09fa8a8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20000125 + - Fix NULL pointer dereference in login.c. Fix from Andre Lucas + + 20000124 - Pick up version 1.2.2 from OpenBSD CVS (no changes, just version number increment) diff --git a/login.c b/login.c index 29259f511..485b9d5e9 100644 --- a/login.c +++ b/login.c @@ -18,7 +18,7 @@ */ #include "includes.h" -RCSID("$Id: login.c,v 1.19 2000/01/23 09:18:36 damien Exp $"); +RCSID("$Id: login.c,v 1.20 2000/01/26 00:04:48 damien Exp $"); #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) # include @@ -173,21 +173,23 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid, strncpy(u.ut_host, host, sizeof(u.ut_host)); #endif #if defined(HAVE_ADDR_IN_UTMP) - switch (addr->sa_family) { - case AF_INET: { - struct sockaddr_in *in = (struct sockaddr_in*)addr; - memcpy(&(u.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr))); - break; - } + if (addr) { + switch (addr->sa_family) { + case AF_INET: { + struct sockaddr_in *in = (struct sockaddr_in*)addr; + memcpy(&(u.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr))); + break; + } #if defined(HAVE_ADDR_V6_IN_UTMP) - case AF_INET6: { - struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr; - memcpy(u.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr))); - break; - } + case AF_INET6: { + struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr; + memcpy(u.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr))); + break; + } #endif - default: - break; + default: + break; + } } #endif @@ -208,21 +210,23 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid, # endif /* HAVE_SYSLEN_IN_UTMPX */ # endif #if defined(HAVE_ADDR_IN_UTMPX) - switch (addr->sa_family) { - case AF_INET: { - struct sockaddr_in *in = (struct sockaddr_in*)addr; - memcpy(&(utx.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr))); - break; - } + if (addr) + switch (addr->sa_family) { + case AF_INET: { + struct sockaddr_in *in = (struct sockaddr_in*)addr; + memcpy(&(utx.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr))); + break; + } #if defined(HAVE_ADDR_V6_IN_UTMPX) - case AF_INET6: { - struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr; - memcpy(utx.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr))); - break; - } + case AF_INET6: { + struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr; + memcpy(utx.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr))); + break; + } #endif - default: - break; + default: + break; + } } #endif #endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */ -- cgit v1.2.3