From 44156f006b0b804604a31571a4df7ae86c9cc789 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 13 Jun 2006 15:18:04 +0000 Subject: [PATCH] POSIX allows getpwnam_r and getpwuid_r to return 0 (success) even if the username or UID could not be found, in which case OUT will be set to NULL. Elsewhere, code assumes that if k5_getpwnam_r or k5_getpwuid_r returns 0, OUT is non-NULL. Check whether OUT is NULL and adjust the return value accordingly in the k5_getpw{nam,uid}_r wrappers. Ticket: 3490 Version_Reported: 1.4.3 Component: krb5-libs git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18121 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/k5-platform.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h index af949dbd4..876335f94 100644 --- a/src/include/k5-platform.h +++ b/src/include/k5-platform.h @@ -664,8 +664,9 @@ load_64_le (const unsigned char *p) #ifdef HAVE_GETPWNAM_R # ifndef GETPWNAM_R_4_ARGS /* POSIX */ -# define k5_getpwnam_r(NAME, REC, BUF, BUFSIZE, OUT) \ - getpwnam_r(NAME,REC,BUF,BUFSIZE,OUT) +# define k5_getpwnam_r(NAME, REC, BUF, BUFSIZE, OUT) \ + (getpwnam_r(NAME,REC,BUF,BUFSIZE,OUT) == 0 \ + ? (*(OUT) == NULL ? -1 : 0) : -1) # else /* POSIX drafts? */ # ifdef GETPWNAM_R_RETURNS_INT @@ -688,8 +689,9 @@ load_64_le (const unsigned char *p) #ifdef HAVE_GETPWUID_R # ifndef GETPWUID_R_4_ARGS /* POSIX */ -# define k5_getpwuid_r(UID, REC, BUF, BUFSIZE, OUT) \ - getpwuid_r(UID,REC,BUF,BUFSIZE,OUT) +# define k5_getpwuid_r(UID, REC, BUF, BUFSIZE, OUT) \ + (getpwuid_r(UID,REC,BUF,BUFSIZE,OUT) == 0 \ + ? (*(OUT) == NULL ? -1 : 0) : -1) # else /* POSIX drafts? Yes, I mean to test GETPWNAM... here. Less junk to do at configure time. */ -- 2.26.2