- Fix NULL pointer dereference in login.c. Fix from Andre Lucas

<andre.lucas@dial.pipex.com>
This commit is contained in:
Damien Miller 2000-01-26 11:04:48 +11:00
parent 68cee109e8
commit d89c24b57e
2 changed files with 35 additions and 27 deletions

View File

@ -1,3 +1,7 @@
20000125
- Fix NULL pointer dereference in login.c. Fix from Andre Lucas
<andre.lucas@dial.pipex.com>
20000124 20000124
- Pick up version 1.2.2 from OpenBSD CVS (no changes, just version number - Pick up version 1.2.2 from OpenBSD CVS (no changes, just version number
increment) increment)

58
login.c
View File

@ -18,7 +18,7 @@
*/ */
#include "includes.h" #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) #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX)
# include <utmpx.h> # include <utmpx.h>
@ -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)); strncpy(u.ut_host, host, sizeof(u.ut_host));
#endif #endif
#if defined(HAVE_ADDR_IN_UTMP) #if defined(HAVE_ADDR_IN_UTMP)
switch (addr->sa_family) { if (addr) {
case AF_INET: { switch (addr->sa_family) {
struct sockaddr_in *in = (struct sockaddr_in*)addr; case AF_INET: {
memcpy(&(u.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr))); struct sockaddr_in *in = (struct sockaddr_in*)addr;
break; memcpy(&(u.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr)));
} break;
}
#if defined(HAVE_ADDR_V6_IN_UTMP) #if defined(HAVE_ADDR_V6_IN_UTMP)
case AF_INET6: { case AF_INET6: {
struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr; struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr;
memcpy(u.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr))); memcpy(u.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr)));
break; break;
} }
#endif #endif
default: default:
break; break;
}
} }
#endif #endif
@ -208,21 +210,23 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid,
# endif /* HAVE_SYSLEN_IN_UTMPX */ # endif /* HAVE_SYSLEN_IN_UTMPX */
# endif # endif
#if defined(HAVE_ADDR_IN_UTMPX) #if defined(HAVE_ADDR_IN_UTMPX)
switch (addr->sa_family) { if (addr)
case AF_INET: { switch (addr->sa_family) {
struct sockaddr_in *in = (struct sockaddr_in*)addr; case AF_INET: {
memcpy(&(utx.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr))); struct sockaddr_in *in = (struct sockaddr_in*)addr;
break; memcpy(&(utx.ut_addr), &(in->sin_addr), sizeof(&(in->sin_addr)));
} break;
}
#if defined(HAVE_ADDR_V6_IN_UTMPX) #if defined(HAVE_ADDR_V6_IN_UTMPX)
case AF_INET6: { case AF_INET6: {
struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr; struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr;
memcpy(utx.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr))); memcpy(utx.ut_addr_v6, &(in6->sin6_addr), sizeof(&(in6->sin6_addr)));
break; break;
} }
#endif #endif
default: default:
break; break;
}
} }
#endif #endif
#endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */ #endif /* defined(HAVE_UTMPX_H) && defined(USE_UTMPX) */