apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1370626 - /apr/apr/trunk/crypto/apr_passwd.c
Date Wed, 08 Aug 2012 01:22:44 GMT
Author: trawick
Date: Wed Aug  8 01:22:44 2012
New Revision: 1370626

URL: http://svn.apache.org/viewvc?rev=1370626&view=rev
Log:
apr_password_validate(): Fix intermittent errors on systems
such as FreeBSD where the crypt() function is used.

Modified:
    apr/apr/trunk/crypto/apr_passwd.c

Modified: apr/apr/trunk/crypto/apr_passwd.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/crypto/apr_passwd.c?rev=1370626&r1=1370625&r2=1370626&view=diff
==============================================================================
--- apr/apr/trunk/crypto/apr_passwd.c (original)
+++ apr/apr/trunk/crypto/apr_passwd.c Wed Aug  8 01:22:44 2012
@@ -160,18 +160,23 @@ APR_DECLARE(apr_status_t) apr_password_v
 #if defined(_AIX) && APR_HAS_THREADS
 #error Configuration error!  crypt_r() should have been selected!
 #endif
+        {
+            apr_status_t rv;
 
-        /* Handle thread safety issues by holding a mutex around the
-         * call to crypt().
-         */
-        crypt_mutex_lock();
-        crypt_pw = crypt(passwd, hash);
-        if (!crypt_pw) {
+            /* Handle thread safety issues by holding a mutex around the
+             * call to crypt().
+             */
+            crypt_mutex_lock();
+            crypt_pw = crypt(passwd, hash);
+            if (!crypt_pw) {
+                rv = APR_EMISMATCH;
+            }
+            else {
+                rv = (strcmp(crypt_pw, hash) == 0) ? APR_SUCCESS : APR_EMISMATCH;
+            }
             crypt_mutex_unlock();
-            return APR_EMISMATCH;
+            return rv;
         }
-        crypt_mutex_unlock();
-        return (strcmp(crypt_pw, hash) == 0) ? APR_SUCCESS : APR_EMISMATCH;
 #endif
     }
     return (strcmp(sample, hash) == 0) ? APR_SUCCESS : APR_EMISMATCH;



Mime
View raw message