]> granicus.if.org Git - apache/commitdiff
remove a thread un-safe function from mod_rewrite
authorRyan Bloom <rbb@apache.org>
Fri, 10 Nov 2000 18:42:40 +0000 (18:42 +0000)
committerRyan Bloom <rbb@apache.org>
Fri, 10 Nov 2000 18:42:40 +0000 (18:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86914 13f79535-47bb-0310-9956-ffa450edef68

modules/mappers/mod_rewrite.c

index 3830fde577ab4a5e09ed4e91218c6295d3f6eaf7..72c91569e5cee5b2ba6b3c56b36df9fe60dbe141 100644 (file)
@@ -2630,6 +2630,11 @@ static char *expand_tildepaths(request_rec *r, char *uri)
     struct passwd *pw;
     char *newuri;
     int i, j;
+#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+    struct passwd pwd;
+    size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+    char *buf = apr_pcalloc(r->pool, buflen);
+#endif
 
     newuri = uri;
     if (uri != NULL && strlen(uri) > 2 && uri[0] == '/' && uri[1] == '~') {
@@ -2642,7 +2647,11 @@ static char *expand_tildepaths(request_rec *r, char *uri)
         user[j] = '\0';
 
         /* lookup username in systems passwd file */
+#if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+        if (!getpwnam_r(user, &pwd, buf, buflen, &pw)) {
+#else
         if ((pw = getpwnam(user)) != NULL) {
+#endif
             /* ok, user was found, so expand the ~user string */
             if (uri[i] != '\0') {
                 /* ~user/anything...  has to be expanded */