apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: svn commit: r219635 - in /apr/apr/trunk: CHANGES user/unix/groupinfo.c user/unix/userinfo.c
Date Tue, 19 Jul 2005 10:11:26 GMT
On Tue, Jul 19, 2005 at 09:38:49AM -0000, Paul Querna wrote:
> Author: pquerna
> Date: Tue Jul 19 02:38:36 2005
> New Revision: 219635
> 
> URL: http://svn.apache.org/viewcvs?rev=219635&view=rev
> Log:
> These functions can return no-error, but still contain a NULL entry, on some crazy unix
that some people use called Linux.

Interestingly the behaviour is correct by a literal interpretation of 
POSIX, which distinguishes the "not found" case from "error" cases.  But 
in any case errno is not used to return errors for the _r functions, so 
this is likely to just propagate the confusion by returning APR_SUCCESS.

I'd guess the correct fix is something like the below: I'd like to do 
some more testing first...

Index: user/unix/userinfo.c
===================================================================
--- user/unix/userinfo.c	(revision 219637)
+++ user/unix/userinfo.c	(working copy)
@@ -114,13 +114,20 @@
 #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R)
     struct passwd pwd;
     char pwbuf[PWBUF_SIZE];
+    apr_status_t rv;
 
-    if (getpwuid_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw) || pw == NULL) {
+    rv = getpwuid_r(userid, &pwd, pwbuf, sizeof(pwbuf), &pw);
+    if (rv) {
+        return rv;
+    }
+    if (pw == NULL) {
+        return APR_ENOENT;
+    }
 #else
     if ((pw = getpwuid(userid)) == NULL) {
-#endif
         return errno;
     }
+#endif
     *username = apr_pstrdup(p, pw->pw_name);
     return APR_SUCCESS;
 }

Mime
View raw message