]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.3' into PHP-7.4
authorChristoph M. Becker <cmbecker69@gmx.de>
Tue, 11 Feb 2020 10:50:42 +0000 (11:50 +0100)
committerChristoph M. Becker <cmbecker69@gmx.de>
Tue, 11 Feb 2020 10:57:57 +0000 (11:57 +0100)
* PHP-7.3:
  Fix #79254: getenv() w/o arguments not showing changes

1  2 
NEWS
main/php_variables.c

diff --cc NEWS
index 44c659ea93a193e1ada5b2e9458c8162d34bcbae,af20e3db3d8840639ad695927d00855dc281328d..1c1b11382ad3f36c122394512855d1ef586a2b85
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -20,18 -12,17 +20,21 @@@ PH
  - PCRE:
    . Fixed bug #79188 (Memory corruption in preg_replace/preg_replace_callback
      and unicode). (Nikita)
 +  . Fixed bug #79241 (Segmentation fault on preg_match()). (Nikita)
  
 -20 Feb 2020, PHP 7.3.15
+ - Standard:
+   . Fixed bug #79254 (getenv() w/o arguments not showing changes). (cmb)
 +?? ??? ????, PHP 7.4.3
  
  - Core:
 -  . Fixed bug #71876 (Memory corruption htmlspecialchars(): charset `*' not
 -    supported). (Nikita)
 -  . Fixed bug ##79146 (cscript can fail to run on some systems). (clarodeus)
 +  . Fixed bug #79146 (cscript can fail to run on some systems). (clarodeus)
 +  . Fixed bug #79155 (Property nullability lost when using multiple property
 +    definition). (Nikita)
    . Fixed bug #78323 (Code 0 is returned on invalid options). (Ivan Mikheykin)
 +  . Fixed bug #78989 (Delayed variance check involving trait segfaults).
 +    (Nikita)
 +  . Fixed bug #79174 (cookie values with spaces fail to round-trip). (cmb)
    . Fixed bug #76047 (Use-after-free when accessing already destructed
      backtrace arguments). (Nikita)
  
index 74fea2c8484df7ca36b492a300f9f181ef45f1c0,d804a3860f4e078d736280addc749ed61a59fc01..1a40c2a19fd22fd19e00db05d3613cbdeddc93ca
@@@ -547,34 -548,49 +547,53 @@@ static zend_always_inline void import_e
        zval val;
        zend_ulong idx;
  
+       p = strchr(env, '=');
+       if (!p
+               || p == env
+               || !valid_environment_name(env, p)) {
+               /* malformed entry? */
+               return;
+       }
+       name_len = p - env;
+       p++;
+       len = strlen(p);
+       if (len == 0) {
+               ZVAL_EMPTY_STRING(&val);
+       } else if (len == 1) {
+               ZVAL_INTERNED_STR(&val, ZSTR_CHAR((zend_uchar)*p));
+       } else {
+               ZVAL_NEW_STR(&val, zend_string_init(p, len, 0));
+       }
+       if (ZEND_HANDLE_NUMERIC_STR(env, name_len, idx)) {
+               zend_hash_index_update(ht, idx, &val);
+       } else {
+               php_register_variable_quick(env, name_len, &val, ht);
+       }
+ }
+ void _php_import_environment_variables(zval *array_ptr)
+ {
+ #ifndef PHP_WIN32
+       char **env;
+ #else
+       char *environment, *env;
+ #endif
 +      tsrm_env_lock();
 +
+ #ifndef PHP_WIN32
        for (env = environ; env != NULL && *env != NULL; env++) {
-               p = strchr(*env, '=');
-               if (!p
-                || p == *env
-                || !valid_environment_name(*env, p)) {
-                       /* malformed entry? */
-                       continue;
-               }
-               name_len = p - *env;
-               p++;
-               len = strlen(p);
-               if (len == 0) {
-                       ZVAL_EMPTY_STRING(&val);
-               } else if (len == 1) {
-                       ZVAL_INTERNED_STR(&val, ZSTR_CHAR((zend_uchar)*p));
-               } else {
-                       ZVAL_NEW_STR(&val, zend_string_init(p, len, 0));
-               }
-               if (ZEND_HANDLE_NUMERIC_STR(*env, name_len, idx)) {
-                       zend_hash_index_update(Z_ARRVAL_P(array_ptr), idx, &val);
-               } else {
-                       php_register_variable_quick(*env, name_len, &val, Z_ARRVAL_P(array_ptr));
-               }
+               import_environment_variable(Z_ARRVAL_P(array_ptr), *env);
        }
+ #else
+       environment = GetEnvironmentStringsA();
+       for (env = environment; env != NULL && *env; env += strlen(env) + 1) {
+               import_environment_variable(Z_ARRVAL_P(array_ptr), env);
+       }
+       FreeEnvironmentStringsA(environment);
+ #endif
 +
 +      tsrm_env_unlock();
  }
  
  zend_bool php_std_auto_global_callback(char *name, uint32_t name_len)