]> granicus.if.org Git - php/commitdiff
Fix potential use-after-scope if crypt_r is used
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 24 Jun 2020 11:06:01 +0000 (13:06 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 24 Jun 2020 11:07:00 +0000 (13:07 +0200)
ext/standard/crypt.c

index 6188dc29204ed71a7cb90a5c949ebcb2a05cf944..18839624d4154e4768e35afa52603021a12240f6 100644 (file)
@@ -181,17 +181,15 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
 #else
 
 # if defined(HAVE_CRYPT_R) && (defined(_REENTRANT) || defined(_THREAD_SAFE))
-       {
 #  if defined(CRYPT_R_STRUCT_CRYPT_DATA)
-               struct crypt_data buffer;
-               memset(&buffer, 0, sizeof(buffer));
+       struct crypt_data buffer;
+       memset(&buffer, 0, sizeof(buffer));
 #  elif defined(CRYPT_R_CRYPTD)
-               CRYPTD buffer;
+       CRYPTD buffer;
 #  else
 #   error Data struct used by crypt_r() is unknown. Please report.
 #  endif
-               crypt_res = crypt_r(password, salt, &buffer);
-       }
+       crypt_res = crypt_r(password, salt, &buffer);
 # elif defined(HAVE_CRYPT)
        crypt_res = crypt(password, salt);
 # else