From: Ryan Bloom Date: Fri, 10 Nov 2000 18:42:40 +0000 (+0000) Subject: remove a thread un-safe function from mod_rewrite X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad50cdf30783ee1c8828a48e6ce1da49dcdd5672;p=apache remove a thread un-safe function from mod_rewrite git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86914 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 3830fde577..72c91569e5 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -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 */