@@ -708,11 +708,14 @@ static PHP_INI_MH(OnUpdateSessionLong) /* {{{ */
708
708
/* }}} */
709
709
710
710
711
- static PHP_INI_MH (OnUpdateSessionString ) /* {{{ */
711
+ static PHP_INI_MH (OnUpdateSessionStr ) /* {{{ */
712
712
{
713
713
SESSION_CHECK_ACTIVE_STATE ;
714
714
SESSION_CHECK_OUTPUT_STATE ;
715
- return OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
715
+
716
+ zend_string * * p = (zend_string * * ) ZEND_INI_GET_ADDR ();
717
+ * p = new_value ? new_value : NULL ;
718
+ return SUCCESS ;
716
719
}
717
720
/* }}} */
718
721
@@ -807,16 +810,16 @@ PHP_INI_BEGIN()
807
810
STD_PHP_INI_ENTRY ("session.gc_maxlifetime" , "1440" , PHP_INI_ALL , OnUpdateSessionLong , gc_maxlifetime , php_ps_globals , ps_globals )
808
811
PHP_INI_ENTRY ("session.serialize_handler" , "php" , PHP_INI_ALL , OnUpdateSerializer )
809
812
STD_PHP_INI_ENTRY ("session.cookie_lifetime" , "0" , PHP_INI_ALL , OnUpdateCookieLifetime ,cookie_lifetime , php_ps_globals , ps_globals )
810
- STD_PHP_INI_ENTRY ("session.cookie_path" , "/" , PHP_INI_ALL , OnUpdateSessionString , cookie_path , php_ps_globals , ps_globals )
811
- STD_PHP_INI_ENTRY ("session.cookie_domain" , "" , PHP_INI_ALL , OnUpdateSessionString , cookie_domain , php_ps_globals , ps_globals )
813
+ STD_PHP_INI_ENTRY ("session.cookie_path" , "/" , PHP_INI_ALL , OnUpdateSessionStr , cookie_path , php_ps_globals , ps_globals )
814
+ STD_PHP_INI_ENTRY ("session.cookie_domain" , "" , PHP_INI_ALL , OnUpdateSessionStr , cookie_domain , php_ps_globals , ps_globals )
812
815
STD_PHP_INI_ENTRY ("session.cookie_secure" , "0" , PHP_INI_ALL , OnUpdateSessionBool , cookie_secure , php_ps_globals , ps_globals )
813
816
STD_PHP_INI_ENTRY ("session.cookie_httponly" , "0" , PHP_INI_ALL , OnUpdateSessionBool , cookie_httponly , php_ps_globals , ps_globals )
814
- STD_PHP_INI_ENTRY ("session.cookie_samesite" , "" , PHP_INI_ALL , OnUpdateSessionString , cookie_samesite , php_ps_globals , ps_globals )
817
+ STD_PHP_INI_ENTRY ("session.cookie_samesite" , "" , PHP_INI_ALL , OnUpdateSessionStr , cookie_samesite , php_ps_globals , ps_globals )
815
818
STD_PHP_INI_ENTRY ("session.use_cookies" , "1" , PHP_INI_ALL , OnUpdateSessionBool , use_cookies , php_ps_globals , ps_globals )
816
819
STD_PHP_INI_ENTRY ("session.use_only_cookies" , "1" , PHP_INI_ALL , OnUpdateSessionBool , use_only_cookies , php_ps_globals , ps_globals )
817
820
STD_PHP_INI_ENTRY ("session.use_strict_mode" , "0" , PHP_INI_ALL , OnUpdateSessionBool , use_strict_mode , php_ps_globals , ps_globals )
818
- STD_PHP_INI_ENTRY ("session.referer_check" , "" , PHP_INI_ALL , OnUpdateSessionString , extern_referer_chk , php_ps_globals , ps_globals )
819
- STD_PHP_INI_ENTRY ("session.cache_limiter" , "nocache" , PHP_INI_ALL , OnUpdateSessionString , cache_limiter , php_ps_globals , ps_globals )
821
+ STD_PHP_INI_ENTRY ("session.referer_check" , "" , PHP_INI_ALL , OnUpdateSessionStr , extern_referer_chk , php_ps_globals , ps_globals )
822
+ STD_PHP_INI_ENTRY ("session.cache_limiter" , "nocache" , PHP_INI_ALL , OnUpdateSessionStr , cache_limiter , php_ps_globals , ps_globals )
820
823
STD_PHP_INI_ENTRY ("session.cache_expire" , "180" , PHP_INI_ALL , OnUpdateSessionLong , cache_expire , php_ps_globals , ps_globals )
821
824
PHP_INI_ENTRY ("session.use_trans_sid" , "0" , PHP_INI_ALL , OnUpdateTransSid )
822
825
PHP_INI_ENTRY ("session.sid_length" , "32" , PHP_INI_ALL , OnUpdateSidLength )
@@ -1229,7 +1232,7 @@ static int php_session_cache_limiter(void) /* {{{ */
1229
1232
{
1230
1233
const php_session_cache_limiter_t * lim ;
1231
1234
1232
- if (PS (cache_limiter )[ 0 ] == '\0' ) return 0 ;
1235
+ if (! PS (cache_limiter ) || ZSTR_LEN ( PS ( cache_limiter )) == 0 ) return 0 ;
1233
1236
if (PS (session_status ) != php_session_active ) return -1 ;
1234
1237
1235
1238
if (SG (headers_sent )) {
@@ -1246,7 +1249,8 @@ static int php_session_cache_limiter(void) /* {{{ */
1246
1249
}
1247
1250
1248
1251
for (lim = php_session_cache_limiters ; lim -> name ; lim ++ ) {
1249
- if (!strcasecmp (lim -> name , PS (cache_limiter ))) {
1252
+ // TODO Use zend_string_cmp API?
1253
+ if (!strcasecmp (lim -> name , ZSTR_VAL (PS (cache_limiter )))) {
1250
1254
lim -> func ();
1251
1255
return 0 ;
1252
1256
}
@@ -1355,14 +1359,14 @@ static zend_result php_session_send_cookie(void) /* {{{ */
1355
1359
}
1356
1360
}
1357
1361
1358
- if (PS (cookie_path )[ 0 ] ) {
1362
+ if (PS (cookie_path ) && ZSTR_LEN ( PS ( cookie_path )) != 0 ) {
1359
1363
smart_str_appends (& ncookie , COOKIE_PATH );
1360
- smart_str_appends (& ncookie , PS (cookie_path ));
1364
+ smart_str_append (& ncookie , PS (cookie_path ));
1361
1365
}
1362
1366
1363
- if (PS (cookie_domain )[ 0 ] ) {
1367
+ if (PS (cookie_domain ) && ZSTR_LEN ( PS ( cookie_domain )) != 0 ) {
1364
1368
smart_str_appends (& ncookie , COOKIE_DOMAIN );
1365
- smart_str_appends (& ncookie , PS (cookie_domain ));
1369
+ smart_str_append (& ncookie , PS (cookie_domain ));
1366
1370
}
1367
1371
1368
1372
if (PS (cookie_secure )) {
@@ -1373,9 +1377,9 @@ static zend_result php_session_send_cookie(void) /* {{{ */
1373
1377
smart_str_appends (& ncookie , COOKIE_HTTPONLY );
1374
1378
}
1375
1379
1376
- if (PS (cookie_samesite )[ 0 ] ) {
1380
+ if (PS (cookie_samesite ) && ZSTR_LEN ( PS ( cookie_samesite )) != 0 ) {
1377
1381
smart_str_appends (& ncookie , COOKIE_SAMESITE );
1378
- smart_str_appends (& ncookie , PS (cookie_samesite ));
1382
+ smart_str_append (& ncookie , PS (cookie_samesite ));
1379
1383
}
1380
1384
1381
1385
smart_str_0 (& ncookie );
@@ -1593,12 +1597,12 @@ PHPAPI zend_result php_session_start(void) /* {{{ */
1593
1597
}
1594
1598
/* Check whether the current request was referred to by
1595
1599
* an external site which invalidates the previously found id. */
1596
- if (PS (id ) && PS (extern_referer_chk )[ 0 ] != '\0' &&
1600
+ if (PS (id ) && PS (extern_referer_chk ) && ZSTR_LEN ( PS ( extern_referer_chk )) != 0 &&
1597
1601
!Z_ISUNDEF (PG (http_globals )[TRACK_VARS_SERVER ]) &&
1598
1602
(data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), "HTTP_REFERER" , sizeof ("HTTP_REFERER" ) - 1 )) &&
1599
1603
Z_TYPE_P (data ) == IS_STRING &&
1600
1604
Z_STRLEN_P (data ) != 0 &&
1601
- strstr (Z_STRVAL_P (data ), PS (extern_referer_chk )) == NULL
1605
+ strstr (Z_STRVAL_P (data ), ZSTR_VAL ( PS (extern_referer_chk ) )) == NULL
1602
1606
) {
1603
1607
zend_string_release_ex (PS (id ), 0 );
1604
1608
PS (id ) = NULL ;
@@ -1856,11 +1860,15 @@ PHP_FUNCTION(session_get_cookie_params)
1856
1860
array_init (return_value );
1857
1861
1858
1862
add_assoc_long (return_value , "lifetime" , PS (cookie_lifetime ));
1859
- add_assoc_string (return_value , "path" , PS (cookie_path ));
1860
- add_assoc_string (return_value , "domain" , PS (cookie_domain ));
1863
+ // TODO Use add_assoc_str() but figure out why it emits a
1864
+ // Zend/zend_types.h:1222: zend_gc_delref: Assertion `(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
1865
+ add_assoc_string (return_value , "path" , ZSTR_VAL (PS (cookie_path )));
1866
+ add_assoc_string (return_value , "domain" , ZSTR_VAL (PS (cookie_domain )));
1861
1867
add_assoc_bool (return_value , "secure" , PS (cookie_secure ));
1862
1868
add_assoc_bool (return_value , "httponly" , PS (cookie_httponly ));
1863
- add_assoc_string (return_value , "samesite" , PS (cookie_samesite ));
1869
+ // TODO Use add_assoc_str() but figure out why it emits a
1870
+ // Zend/zend_types.h:1222: zend_gc_delref: Assertion `(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
1871
+ add_assoc_string (return_value , "samesite" , ZSTR_VAL (PS (cookie_samesite )));
1864
1872
}
1865
1873
/* }}} */
1866
1874
@@ -2385,7 +2393,14 @@ PHP_FUNCTION(session_cache_limiter)
2385
2393
RETURN_FALSE ;
2386
2394
}
2387
2395
2388
- RETVAL_STRING (PS (cache_limiter ));
2396
+ // TODO use RETVAL_STR, this is crappy code is done to circumvent a
2397
+ // Zend/zend_types.h:1222: zend_gc_delref: Assertion `(zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7)' failed.
2398
+ // that I don't understand... - Girgias
2399
+ zend_string * result_str = PS (cache_limiter );
2400
+ if (!result_str ) {
2401
+ result_str = zend_empty_string ;
2402
+ }
2403
+ RETVAL_STRING (ZSTR_VAL (result_str ));
2389
2404
2390
2405
if (limiter ) {
2391
2406
ini_name = zend_string_init ("session.cache_limiter" , sizeof ("session.cache_limiter" ) - 1 , 0 );
0 commit comments