@@ -692,11 +692,14 @@ static PHP_INI_MH(OnUpdateSessionLong) /* {{{ */
692
692
/* }}} */
693
693
694
694
695
- static PHP_INI_MH (OnUpdateSessionString ) /* {{{ */
695
+ static PHP_INI_MH (OnUpdateSessionStr ) /* {{{ */
696
696
{
697
697
SESSION_CHECK_ACTIVE_STATE ;
698
698
SESSION_CHECK_OUTPUT_STATE ;
699
- return OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
699
+
700
+ zend_string * * p = (zend_string * * ) ZEND_INI_GET_ADDR ();
701
+ * p = new_value ? new_value : NULL ;
702
+ return SUCCESS ;
700
703
}
701
704
/* }}} */
702
705
@@ -780,16 +783,16 @@ PHP_INI_BEGIN()
780
783
STD_PHP_INI_ENTRY ("session.gc_maxlifetime" , "1440" , PHP_INI_ALL , OnUpdateSessionLong , gc_maxlifetime , php_ps_globals , ps_globals )
781
784
PHP_INI_ENTRY ("session.serialize_handler" , "php" , PHP_INI_ALL , OnUpdateSerializer )
782
785
STD_PHP_INI_ENTRY ("session.cookie_lifetime" , "0" , PHP_INI_ALL , OnUpdateCookieLifetime ,cookie_lifetime , php_ps_globals , ps_globals )
783
- STD_PHP_INI_ENTRY ("session.cookie_path" , "/" , PHP_INI_ALL , OnUpdateSessionString , cookie_path , php_ps_globals , ps_globals )
784
- STD_PHP_INI_ENTRY ("session.cookie_domain" , "" , PHP_INI_ALL , OnUpdateSessionString , cookie_domain , php_ps_globals , ps_globals )
786
+ STD_PHP_INI_ENTRY ("session.cookie_path" , "/" , PHP_INI_ALL , OnUpdateSessionStr , cookie_path , php_ps_globals , ps_globals )
787
+ STD_PHP_INI_ENTRY ("session.cookie_domain" , "" , PHP_INI_ALL , OnUpdateSessionStr , cookie_domain , php_ps_globals , ps_globals )
785
788
STD_PHP_INI_ENTRY ("session.cookie_secure" , "0" , PHP_INI_ALL , OnUpdateSessionBool , cookie_secure , php_ps_globals , ps_globals )
786
789
STD_PHP_INI_ENTRY ("session.cookie_httponly" , "0" , PHP_INI_ALL , OnUpdateSessionBool , cookie_httponly , php_ps_globals , ps_globals )
787
- STD_PHP_INI_ENTRY ("session.cookie_samesite" , "" , PHP_INI_ALL , OnUpdateSessionString , cookie_samesite , php_ps_globals , ps_globals )
790
+ STD_PHP_INI_ENTRY ("session.cookie_samesite" , "" , PHP_INI_ALL , OnUpdateSessionStr , cookie_samesite , php_ps_globals , ps_globals )
788
791
STD_PHP_INI_ENTRY ("session.use_cookies" , "1" , PHP_INI_ALL , OnUpdateSessionBool , use_cookies , php_ps_globals , ps_globals )
789
792
STD_PHP_INI_ENTRY ("session.use_only_cookies" , "1" , PHP_INI_ALL , OnUpdateSessionBool , use_only_cookies , php_ps_globals , ps_globals )
790
793
STD_PHP_INI_ENTRY ("session.use_strict_mode" , "0" , PHP_INI_ALL , OnUpdateSessionBool , use_strict_mode , php_ps_globals , ps_globals )
791
- STD_PHP_INI_ENTRY ("session.referer_check" , "" , PHP_INI_ALL , OnUpdateSessionString , extern_referer_chk , php_ps_globals , ps_globals )
792
- STD_PHP_INI_ENTRY ("session.cache_limiter" , "nocache" , PHP_INI_ALL , OnUpdateSessionString , cache_limiter , php_ps_globals , ps_globals )
794
+ STD_PHP_INI_ENTRY ("session.referer_check" , "" , PHP_INI_ALL , OnUpdateSessionStr , extern_referer_chk , php_ps_globals , ps_globals )
795
+ STD_PHP_INI_ENTRY ("session.cache_limiter" , "nocache" , PHP_INI_ALL , OnUpdateSessionStr , cache_limiter , php_ps_globals , ps_globals )
793
796
STD_PHP_INI_ENTRY ("session.cache_expire" , "180" , PHP_INI_ALL , OnUpdateSessionLong , cache_expire , php_ps_globals , ps_globals )
794
797
STD_PHP_INI_BOOLEAN ("session.use_trans_sid" , "0" , PHP_INI_ALL , OnUpdateSessionBool , use_trans_sid , php_ps_globals , ps_globals )
795
798
PHP_INI_ENTRY ("session.sid_length" , "32" , PHP_INI_ALL , OnUpdateSidLength )
@@ -1202,7 +1205,7 @@ static int php_session_cache_limiter(void) /* {{{ */
1202
1205
{
1203
1206
const php_session_cache_limiter_t * lim ;
1204
1207
1205
- if (PS (cache_limiter )[ 0 ] == '\0' ) return 0 ;
1208
+ if (! PS (cache_limiter ) || ZSTR_LEN ( PS ( cache_limiter )) == 0 ) return 0 ;
1206
1209
if (PS (session_status ) != php_session_active ) return -1 ;
1207
1210
1208
1211
if (SG (headers_sent )) {
@@ -1219,7 +1222,8 @@ static int php_session_cache_limiter(void) /* {{{ */
1219
1222
}
1220
1223
1221
1224
for (lim = php_session_cache_limiters ; lim -> name ; lim ++ ) {
1222
- if (!strcasecmp (lim -> name , PS (cache_limiter ))) {
1225
+ // TODO Use zend_string_cmp API?
1226
+ if (!strcasecmp (lim -> name , ZSTR_VAL (PS (cache_limiter )))) {
1223
1227
lim -> func ();
1224
1228
return 0 ;
1225
1229
}
@@ -1328,14 +1332,14 @@ static zend_result php_session_send_cookie(void) /* {{{ */
1328
1332
}
1329
1333
}
1330
1334
1331
- if (PS (cookie_path )[ 0 ] ) {
1335
+ if (PS (cookie_path ) && ZSTR_LEN ( PS ( cookie_path )) != 0 ) {
1332
1336
smart_str_appends (& ncookie , COOKIE_PATH );
1333
- smart_str_appends (& ncookie , PS (cookie_path ));
1337
+ smart_str_append (& ncookie , PS (cookie_path ));
1334
1338
}
1335
1339
1336
- if (PS (cookie_domain )[ 0 ] ) {
1340
+ if (PS (cookie_domain ) && ZSTR_LEN ( PS ( cookie_domain )) != 0 ) {
1337
1341
smart_str_appends (& ncookie , COOKIE_DOMAIN );
1338
- smart_str_appends (& ncookie , PS (cookie_domain ));
1342
+ smart_str_append (& ncookie , PS (cookie_domain ));
1339
1343
}
1340
1344
1341
1345
if (PS (cookie_secure )) {
@@ -1346,9 +1350,9 @@ static zend_result php_session_send_cookie(void) /* {{{ */
1346
1350
smart_str_appends (& ncookie , COOKIE_HTTPONLY );
1347
1351
}
1348
1352
1349
- if (PS (cookie_samesite )[ 0 ] ) {
1353
+ if (PS (cookie_samesite ) && ZSTR_LEN ( PS ( cookie_samesite )) != 0 ) {
1350
1354
smart_str_appends (& ncookie , COOKIE_SAMESITE );
1351
- smart_str_appends (& ncookie , PS (cookie_samesite ));
1355
+ smart_str_append (& ncookie , PS (cookie_samesite ));
1352
1356
}
1353
1357
1354
1358
smart_str_0 (& ncookie );
@@ -1566,12 +1570,12 @@ PHPAPI zend_result php_session_start(void) /* {{{ */
1566
1570
}
1567
1571
/* Check whether the current request was referred to by
1568
1572
* an external site which invalidates the previously found id. */
1569
- if (PS (id ) && PS (extern_referer_chk )[ 0 ] != '\0' &&
1573
+ if (PS (id ) && PS (extern_referer_chk ) && ZSTR_LEN ( PS ( extern_referer_chk )) != 0 &&
1570
1574
!Z_ISUNDEF (PG (http_globals )[TRACK_VARS_SERVER ]) &&
1571
1575
(data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), "HTTP_REFERER" , sizeof ("HTTP_REFERER" ) - 1 )) &&
1572
1576
Z_TYPE_P (data ) == IS_STRING &&
1573
1577
Z_STRLEN_P (data ) != 0 &&
1574
- strstr (Z_STRVAL_P (data ), PS (extern_referer_chk )) == NULL
1578
+ strstr (Z_STRVAL_P (data ), ZSTR_VAL ( PS (extern_referer_chk ) )) == NULL
1575
1579
) {
1576
1580
zend_string_release_ex (PS (id ), 0 );
1577
1581
PS (id ) = NULL ;
@@ -1829,11 +1833,15 @@ PHP_FUNCTION(session_get_cookie_params)
1829
1833
array_init (return_value );
1830
1834
1831
1835
add_assoc_long (return_value , "lifetime" , PS (cookie_lifetime ));
1832
- add_assoc_string (return_value , "path" , PS (cookie_path ));
1833
- add_assoc_string (return_value , "domain" , PS (cookie_domain ));
1836
+ // TODO Use add_assoc_str() but figure out why it emits a
1837
+ // Zend/zend_types.h:1222: zend_gc_delref: Assertion `(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
1838
+ add_assoc_string (return_value , "path" , ZSTR_VAL (PS (cookie_path )));
1839
+ add_assoc_string (return_value , "domain" , ZSTR_VAL (PS (cookie_domain )));
1834
1840
add_assoc_bool (return_value , "secure" , PS (cookie_secure ));
1835
1841
add_assoc_bool (return_value , "httponly" , PS (cookie_httponly ));
1836
- add_assoc_string (return_value , "samesite" , PS (cookie_samesite ));
1842
+ // TODO Use add_assoc_str() but figure out why it emits a
1843
+ // Zend/zend_types.h:1222: zend_gc_delref: Assertion `(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
1844
+ add_assoc_string (return_value , "samesite" , ZSTR_VAL (PS (cookie_samesite )));
1837
1845
}
1838
1846
/* }}} */
1839
1847
@@ -2358,7 +2366,12 @@ PHP_FUNCTION(session_cache_limiter)
2358
2366
RETURN_FALSE ;
2359
2367
}
2360
2368
2361
- RETVAL_STRING (PS (cache_limiter ));
2369
+ zend_string * result_str = PS (cache_limiter );
2370
+ if (!result_str ) {
2371
+ result_str = zend_empty_string ;
2372
+ }
2373
+ // TODO Prevent duplication???
2374
+ RETVAL_STR (zend_string_dup (result_str , false));
2362
2375
2363
2376
if (limiter ) {
2364
2377
ini_name = zend_string_init ("session.cache_limiter" , sizeof ("session.cache_limiter" ) - 1 , 0 );
0 commit comments