Skip to content

Commit 187d7f0

Browse files
committed
Fix potential use-after-scope if crypt_r is used
1 parent d579b10 commit 187d7f0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/standard/crypt.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,15 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
181181
#else
182182

183183
# if defined(HAVE_CRYPT_R) && (defined(_REENTRANT) || defined(_THREAD_SAFE))
184-
{
185184
# if defined(CRYPT_R_STRUCT_CRYPT_DATA)
186-
struct crypt_data buffer;
187-
memset(&buffer, 0, sizeof(buffer));
185+
struct crypt_data buffer;
186+
memset(&buffer, 0, sizeof(buffer));
188187
# elif defined(CRYPT_R_CRYPTD)
189-
CRYPTD buffer;
188+
CRYPTD buffer;
190189
# else
191190
# error Data struct used by crypt_r() is unknown. Please report.
192191
# endif
193-
crypt_res = crypt_r(password, salt, &buffer);
194-
}
192+
crypt_res = crypt_r(password, salt, &buffer);
195193
# elif defined(HAVE_CRYPT)
196194
crypt_res = crypt(password, salt);
197195
# else

0 commit comments

Comments
 (0)