@@ -734,11 +734,14 @@ static PHP_INI_MH(OnUpdateSessionLong) /* {{{ */
734
734
/* }}} */
735
735
736
736
737
- static PHP_INI_MH (OnUpdateSessionString ) /* {{{ */
737
+ static PHP_INI_MH (OnUpdateSessionStr ) /* {{{ */
738
738
{
739
739
SESSION_CHECK_ACTIVE_STATE ;
740
740
SESSION_CHECK_OUTPUT_STATE ;
741
- return OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
741
+
742
+ zend_string * * p = (zend_string * * ) ZEND_INI_GET_ADDR ();
743
+ * p = new_value ? new_value : NULL ;
744
+ return SUCCESS ;
742
745
}
743
746
/* }}} */
744
747
@@ -900,16 +903,16 @@ PHP_INI_BEGIN()
900
903
STD_PHP_INI_ENTRY ("session.gc_maxlifetime" , "1440" , PHP_INI_ALL , OnUpdateSessionLong , gc_maxlifetime , php_ps_globals , ps_globals )
901
904
PHP_INI_ENTRY ("session.serialize_handler" , "php" , PHP_INI_ALL , OnUpdateSerializer )
902
905
STD_PHP_INI_ENTRY ("session.cookie_lifetime" , "0" , PHP_INI_ALL , OnUpdateCookieLifetime ,cookie_lifetime , php_ps_globals , ps_globals )
903
- STD_PHP_INI_ENTRY ("session.cookie_path" , "/" , PHP_INI_ALL , OnUpdateSessionString , cookie_path , php_ps_globals , ps_globals )
904
- STD_PHP_INI_ENTRY ("session.cookie_domain" , "" , PHP_INI_ALL , OnUpdateSessionString , cookie_domain , php_ps_globals , ps_globals )
906
+ STD_PHP_INI_ENTRY ("session.cookie_path" , "/" , PHP_INI_ALL , OnUpdateSessionStr , cookie_path , php_ps_globals , ps_globals )
907
+ STD_PHP_INI_ENTRY ("session.cookie_domain" , "" , PHP_INI_ALL , OnUpdateSessionStr , cookie_domain , php_ps_globals , ps_globals )
905
908
STD_PHP_INI_BOOLEAN ("session.cookie_secure" , "0" , PHP_INI_ALL , OnUpdateSessionBool , cookie_secure , php_ps_globals , ps_globals )
906
909
STD_PHP_INI_BOOLEAN ("session.cookie_httponly" , "0" , PHP_INI_ALL , OnUpdateSessionBool , cookie_httponly , php_ps_globals , ps_globals )
907
- STD_PHP_INI_ENTRY ("session.cookie_samesite" , "" , PHP_INI_ALL , OnUpdateSessionString , cookie_samesite , php_ps_globals , ps_globals )
910
+ STD_PHP_INI_ENTRY ("session.cookie_samesite" , "" , PHP_INI_ALL , OnUpdateSessionStr , cookie_samesite , php_ps_globals , ps_globals )
908
911
STD_PHP_INI_BOOLEAN ("session.use_cookies" , "1" , PHP_INI_ALL , OnUpdateSessionBool , use_cookies , php_ps_globals , ps_globals )
909
912
STD_PHP_INI_BOOLEAN ("session.use_only_cookies" , "1" , PHP_INI_ALL , OnUpdateUseOnlyCookies , use_only_cookies , php_ps_globals , ps_globals )
910
913
STD_PHP_INI_BOOLEAN ("session.use_strict_mode" , "0" , PHP_INI_ALL , OnUpdateSessionBool , use_strict_mode , php_ps_globals , ps_globals )
911
- STD_PHP_INI_ENTRY ("session.referer_check" , "" , PHP_INI_ALL , OnUpdateRefererCheck , extern_referer_chk , php_ps_globals , ps_globals )
912
- STD_PHP_INI_ENTRY ("session.cache_limiter" , "nocache" , PHP_INI_ALL , OnUpdateSessionString , cache_limiter , php_ps_globals , ps_globals )
914
+ STD_PHP_INI_ENTRY ("session.referer_check" , "" , PHP_INI_ALL , OnUpdateSessionStr , extern_referer_chk , php_ps_globals , ps_globals )
915
+ STD_PHP_INI_ENTRY ("session.cache_limiter" , "nocache" , PHP_INI_ALL , OnUpdateSessionStr , cache_limiter , php_ps_globals , ps_globals )
913
916
STD_PHP_INI_ENTRY ("session.cache_expire" , "180" , PHP_INI_ALL , OnUpdateSessionLong , cache_expire , php_ps_globals , ps_globals )
914
917
STD_PHP_INI_BOOLEAN ("session.use_trans_sid" , "0" , PHP_INI_ALL , OnUpdateUseTransSid , use_trans_sid , php_ps_globals , ps_globals )
915
918
PHP_INI_ENTRY ("session.sid_length" , "32" , PHP_INI_ALL , OnUpdateSidLength )
@@ -1323,7 +1326,7 @@ static int php_session_cache_limiter(void) /* {{{ */
1323
1326
{
1324
1327
const php_session_cache_limiter_t * lim ;
1325
1328
1326
- if (PS (cache_limiter )[ 0 ] == '\0' ) return 0 ;
1329
+ if (! PS (cache_limiter ) || ZSTR_LEN ( PS ( cache_limiter )) == 0 ) return 0 ;
1327
1330
if (PS (session_status ) != php_session_active ) return -1 ;
1328
1331
1329
1332
if (SG (headers_sent )) {
@@ -1340,7 +1343,8 @@ static int php_session_cache_limiter(void) /* {{{ */
1340
1343
}
1341
1344
1342
1345
for (lim = php_session_cache_limiters ; lim -> name ; lim ++ ) {
1343
- if (!strcasecmp (lim -> name , PS (cache_limiter ))) {
1346
+ // TODO Use zend_string_cmp API?
1347
+ if (!strcasecmp (lim -> name , ZSTR_VAL (PS (cache_limiter )))) {
1344
1348
lim -> func ();
1345
1349
return 0 ;
1346
1350
}
@@ -1449,14 +1453,14 @@ static zend_result php_session_send_cookie(void) /* {{{ */
1449
1453
}
1450
1454
}
1451
1455
1452
- if (PS (cookie_path )[ 0 ] ) {
1456
+ if (PS (cookie_path ) && ZSTR_LEN ( PS ( cookie_path )) != 0 ) {
1453
1457
smart_str_appends (& ncookie , COOKIE_PATH );
1454
- smart_str_appends (& ncookie , PS (cookie_path ));
1458
+ smart_str_append (& ncookie , PS (cookie_path ));
1455
1459
}
1456
1460
1457
- if (PS (cookie_domain )[ 0 ] ) {
1461
+ if (PS (cookie_domain ) && ZSTR_LEN ( PS ( cookie_domain )) != 0 ) {
1458
1462
smart_str_appends (& ncookie , COOKIE_DOMAIN );
1459
- smart_str_appends (& ncookie , PS (cookie_domain ));
1463
+ smart_str_append (& ncookie , PS (cookie_domain ));
1460
1464
}
1461
1465
1462
1466
if (PS (cookie_secure )) {
@@ -1467,9 +1471,9 @@ static zend_result php_session_send_cookie(void) /* {{{ */
1467
1471
smart_str_appends (& ncookie , COOKIE_HTTPONLY );
1468
1472
}
1469
1473
1470
- if (PS (cookie_samesite )[ 0 ] ) {
1474
+ if (PS (cookie_samesite ) && ZSTR_LEN ( PS ( cookie_samesite )) != 0 ) {
1471
1475
smart_str_appends (& ncookie , COOKIE_SAMESITE );
1472
- smart_str_appends (& ncookie , PS (cookie_samesite ));
1476
+ smart_str_append (& ncookie , PS (cookie_samesite ));
1473
1477
}
1474
1478
1475
1479
smart_str_0 (& ncookie );
@@ -1679,12 +1683,12 @@ PHPAPI zend_result php_session_start(void) /* {{{ */
1679
1683
}
1680
1684
/* Check whether the current request was referred to by
1681
1685
* an external site which invalidates the previously found id. */
1682
- if (PS (id ) && PS (extern_referer_chk )[ 0 ] != '\0' &&
1686
+ if (PS (id ) && PS (extern_referer_chk ) && ZSTR_LEN ( PS ( extern_referer_chk )) != 0 &&
1683
1687
!Z_ISUNDEF (PG (http_globals )[TRACK_VARS_SERVER ]) &&
1684
1688
(data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), "HTTP_REFERER" , sizeof ("HTTP_REFERER" ) - 1 )) &&
1685
1689
Z_TYPE_P (data ) == IS_STRING &&
1686
1690
Z_STRLEN_P (data ) != 0 &&
1687
- strstr (Z_STRVAL_P (data ), PS (extern_referer_chk )) == NULL
1691
+ strstr (Z_STRVAL_P (data ), ZSTR_VAL ( PS (extern_referer_chk ) )) == NULL
1688
1692
) {
1689
1693
zend_string_release_ex (PS (id ), 0 );
1690
1694
PS (id ) = NULL ;
@@ -1949,11 +1953,15 @@ PHP_FUNCTION(session_get_cookie_params)
1949
1953
array_init (return_value );
1950
1954
1951
1955
add_assoc_long (return_value , "lifetime" , PS (cookie_lifetime ));
1952
- add_assoc_string (return_value , "path" , PS (cookie_path ));
1953
- add_assoc_string (return_value , "domain" , PS (cookie_domain ));
1956
+ // TODO Use add_assoc_str() but figure out why it emits a
1957
+ // Zend/zend_types.h:1222: zend_gc_delref: Assertion `(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
1958
+ add_assoc_string (return_value , "path" , ZSTR_VAL (PS (cookie_path )));
1959
+ add_assoc_string (return_value , "domain" , ZSTR_VAL (PS (cookie_domain )));
1954
1960
add_assoc_bool (return_value , "secure" , PS (cookie_secure ));
1955
1961
add_assoc_bool (return_value , "httponly" , PS (cookie_httponly ));
1956
- add_assoc_string (return_value , "samesite" , PS (cookie_samesite ));
1962
+ // TODO Use add_assoc_str() but figure out why it emits a
1963
+ // Zend/zend_types.h:1222: zend_gc_delref: Assertion `(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
1964
+ add_assoc_string (return_value , "samesite" , ZSTR_VAL (PS (cookie_samesite )));
1957
1965
}
1958
1966
/* }}} */
1959
1967
@@ -2530,7 +2538,12 @@ PHP_FUNCTION(session_cache_limiter)
2530
2538
RETURN_FALSE ;
2531
2539
}
2532
2540
2533
- RETVAL_STRING (PS (cache_limiter ));
2541
+ zend_string * result_str = PS (cache_limiter );
2542
+ if (!result_str ) {
2543
+ result_str = zend_empty_string ;
2544
+ }
2545
+ // TODO Prevent duplication???
2546
+ RETVAL_STR (zend_string_dup (result_str , false));
2534
2547
2535
2548
if (limiter ) {
2536
2549
ini_name = ZSTR_INIT_LITERAL ("session.cache_limiter" , 0 );
0 commit comments