]> granicus.if.org Git - php/commitdiff
MFB: Use reantrant crypt_r() whenever possible.
authorIlia Alshanetsky <iliaa@php.net>
Thu, 30 Nov 2006 16:00:05 +0000 (16:00 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 30 Nov 2006 16:00:05 +0000 (16:00 +0000)
ext/standard/crypt.c

index 7d1eea0b765b8e3c1f492395ed7993beb3ba6d58..97ff2fc04d3deb2229a1041128621e0b998045d3 100644 (file)
@@ -145,8 +145,15 @@ PHP_FUNCTION(crypt)
                salt[2] = '\0';
 #endif
        }
-
-       RETVAL_STRING(crypt(str, salt), 1);
+#ifdef HAVE_CRYPT_R
+       {
+               struct crypt_data buffer;
+               memset(&buffer, 0, sizeof(buffer));
+               RETURN_STRING(crypt_r(str, salt, &buffer));
+       }
+#else
+       RETURN_STRING(crypt(str, salt), 1);
+#endif
 }
 /* }}} */
 #endif