Skip to content

Commit 891bd78

Browse files
author
Ilia Alshanetsky
committed
Use reantrant crypt_r() whenever possible.
1 parent 20b92bf commit 891bd78

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ext/standard/crypt.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,15 @@ PHP_FUNCTION(crypt)
145145
salt[2] = '\0';
146146
#endif
147147
}
148-
149-
RETVAL_STRING(crypt(str, salt), 1);
148+
#ifdef HAVE_CRYPT_R
149+
{
150+
struct crypt_data buffer;
151+
memset(&buffer, 0, sizeof(buffer));
152+
RETURN_STRING(crypt_r(str, salt, &buffer));
153+
}
154+
#else
155+
RETURN_STRING(crypt(str, salt), 1);
156+
#endif
150157
}
151158
/* }}} */
152159
#endif

0 commit comments

Comments
 (0)