getpw*_r() may return 0 and set pwd==NULL

This commit is contained in:
lukem 2005-04-19 03:38:08 +00:00
parent b9b92f846c
commit a767f5ec9c
3 changed files with 10 additions and 8 deletions

View File

@ -32,7 +32,7 @@
#if 0
static char sccsid[] = "@(#)cuserid.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: cuserid.c,v 1.7 2005/04/01 12:51:07 christos Exp $");
__RCSID("$NetBSD: cuserid.c,v 1.8 2005/04/19 03:38:08 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -50,7 +50,8 @@ cuserid(char *s)
/* s may be NULL */
if (getpwuid_r(geteuid(), &pwres, pwbuf, sizeof(pwbuf), &pw) != 0) {
if (getpwuid_r(geteuid(), &pwres, pwbuf, sizeof(pwbuf), &pw) != 0
|| pw == NULL) {
if (s != NULL)
*s = '\0';
return s;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pam_krb5.c,v 1.8 2005/04/19 03:15:35 christos Exp $ */
/* $NetBSD: pam_krb5.c,v 1.9 2005/04/19 03:38:47 lukem Exp $ */
/*-
* This pam_krb5 module contains code that is:
@ -53,7 +53,7 @@
#ifdef __FreeBSD__
__FBSDID("$FreeBSD: src/lib/libpam/modules/pam_krb5/pam_krb5.c,v 1.22 2005/01/24 16:49:50 rwatson Exp $");
#else
__RCSID("$NetBSD: pam_krb5.c,v 1.8 2005/04/19 03:15:35 christos Exp $");
__RCSID("$NetBSD: pam_krb5.c,v 1.9 2005/04/19 03:38:47 lukem Exp $");
#endif
#include <sys/types.h>
@ -414,7 +414,8 @@ pam_sm_setcred(pam_handle_t *pamh, int flags,
}
/* Get the uid. This should exist. */
if (getpwnam_r(user, &pwres, pwbuf, sizeof(pwbuf), &pwd) != 0) {
if (getpwnam_r(user, &pwres, pwbuf, sizeof(pwbuf), &pwd) != 0 ||
pwd == NULL) {
retval = PAM_USER_UNKNOWN;
goto cleanup3;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.12 2005/04/10 08:05:40 christos Exp $ */
/* $NetBSD: options.c,v 1.13 2005/04/19 03:38:19 lukem Exp $ */
/*
* General skeleton for adding options to the access control language. The
@ -35,7 +35,7 @@
#if 0
static char sccsid[] = "@(#) options.c 1.17 96/02/11 17:01:31";
#else
__RCSID("$NetBSD: options.c,v 1.12 2005/04/10 08:05:40 christos Exp $");
__RCSID("$NetBSD: options.c,v 1.13 2005/04/19 03:38:19 lukem Exp $");
#endif
#endif
@ -298,7 +298,7 @@ struct request_info *request;
if ((group = split_at(value, '.')) != 0)
group_option(group, request);
if (getpwnam_r(value, &pws, pwbuf, sizeof(pwbuf), &pwd) != 0)
if (getpwnam_r(value, &pws, pwbuf, sizeof(pwbuf), &pwd) != 0 || pwd == NULL)
tcpd_jump("unknown user: \"%s\"", value);
endpwent();