@@ -425,7 +425,7 @@ static zend_result php_session_initialize(void)
425
425
}
426
426
427
427
/* Open session handler first */
428
- if (PS (mod )-> s_open (& PS (mod_data ), ZSTR_VAL (PS (save_path )), PS (session_name )) == FAILURE
428
+ if (PS (mod )-> s_open (& PS (mod_data ), ZSTR_VAL (PS (save_path )), ZSTR_VAL ( PS (session_name ) )) == FAILURE
429
429
/* || PS(mod_data) == NULL */ /* FIXME: open must set valid PS(mod_data) with success */
430
430
) {
431
431
php_session_abort ();
@@ -706,7 +706,7 @@ static PHP_INI_MH(OnUpdateName)
706
706
return FAILURE ;
707
707
}
708
708
709
- return OnUpdateStringUnempty (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
709
+ return OnUpdateStrNotEmpty (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage );
710
710
}
711
711
712
712
@@ -1349,10 +1349,9 @@ static void php_session_remove_cookie(void) {
1349
1349
size_t session_cookie_len ;
1350
1350
size_t len = sizeof ("Set-Cookie" )- 1 ;
1351
1351
1352
- ZEND_ASSERT (strpbrk (PS (session_name ), SESSION_FORBIDDEN_CHARS ) == NULL );
1353
- spprintf (& session_cookie , 0 , "Set-Cookie: %s=" , PS (session_name ));
1352
+ ZEND_ASSERT (strpbrk (ZSTR_VAL ( PS (session_name ) ), SESSION_FORBIDDEN_CHARS ) == NULL );
1353
+ session_cookie_len = spprintf (& session_cookie , 0 , "Set-Cookie: %s=" , ZSTR_VAL ( PS (session_name ) ));
1354
1354
1355
- session_cookie_len = strlen (session_cookie );
1356
1355
current = l -> head ;
1357
1356
while (current ) {
1358
1357
header = (sapi_header_struct * )(current -> data );
@@ -1389,13 +1388,13 @@ static zend_result php_session_send_cookie(void)
1389
1388
return FAILURE ;
1390
1389
}
1391
1390
1392
- ZEND_ASSERT (strpbrk (PS (session_name ), SESSION_FORBIDDEN_CHARS ) == NULL );
1391
+ ZEND_ASSERT (strpbrk (ZSTR_VAL ( PS (session_name ) ), SESSION_FORBIDDEN_CHARS ) == NULL );
1393
1392
1394
1393
/* URL encode id because it might be user supplied */
1395
1394
e_id = php_url_encode (ZSTR_VAL (PS (id )), ZSTR_LEN (PS (id )));
1396
1395
1397
1396
smart_str_appends (& ncookie , "Set-Cookie: " );
1398
- smart_str_appendl (& ncookie , PS (session_name ), strlen ( PS ( session_name ) ));
1397
+ smart_str_append (& ncookie , PS (session_name ));
1399
1398
smart_str_appendc (& ncookie , '=' );
1400
1399
smart_str_append (& ncookie , e_id );
1401
1400
@@ -1521,7 +1520,7 @@ PHPAPI zend_result php_session_reset_id(void)
1521
1520
if (PS (define_sid )) {
1522
1521
smart_str var = {0 };
1523
1522
1524
- smart_str_appends (& var , PS (session_name ));
1523
+ smart_str_append (& var , PS (session_name ));
1525
1524
smart_str_appendc (& var , '=' );
1526
1525
smart_str_append (& var , PS (id ));
1527
1526
smart_str_0 (& var );
@@ -1549,18 +1548,15 @@ PHPAPI zend_result php_session_reset_id(void)
1549
1548
(data = zend_hash_str_find (& EG (symbol_table ), ZEND_STRL ("_COOKIE" )))) {
1550
1549
ZVAL_DEREF (data );
1551
1550
if (Z_TYPE_P (data ) == IS_ARRAY &&
1552
- (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), strlen ( PS ( session_name ) )))) {
1551
+ (ppid = zend_hash_find (Z_ARRVAL_P (data ), PS (session_name )))) {
1553
1552
ZVAL_DEREF (ppid );
1554
1553
apply_trans_sid = 0 ;
1555
1554
}
1556
1555
}
1557
1556
}
1558
1557
if (apply_trans_sid ) {
1559
- zend_string * sname ;
1560
- sname = zend_string_init (PS (session_name ), strlen (PS (session_name )), 0 );
1561
- php_url_scanner_reset_session_var (sname , 1 ); /* This may fail when session name has changed */
1562
- zend_string_release_ex (sname , 0 );
1563
- php_url_scanner_add_session_var (PS (session_name ), strlen (PS (session_name )), ZSTR_VAL (PS (id )), ZSTR_LEN (PS (id )), 1 );
1558
+ php_url_scanner_reset_session_var (PS (session_name ), true); /* This may fail when session name has changed */
1559
+ php_url_scanner_add_session_var (ZSTR_VAL (PS (session_name )), ZSTR_LEN (PS (session_name )), ZSTR_VAL (PS (id )), ZSTR_LEN (PS (id )), true);
1564
1560
}
1565
1561
return SUCCESS ;
1566
1562
}
@@ -1571,7 +1567,6 @@ PHPAPI zend_result php_session_start(void)
1571
1567
zval * ppid ;
1572
1568
zval * data ;
1573
1569
char * value ;
1574
- size_t lensess ;
1575
1570
1576
1571
switch (PS (session_status )) {
1577
1572
case php_session_active :
@@ -1606,8 +1601,6 @@ PHPAPI zend_result php_session_start(void)
1606
1601
PS (send_cookie ) = PS (use_cookies ) || PS (use_only_cookies );
1607
1602
}
1608
1603
1609
- lensess = strlen (PS (session_name ));
1610
-
1611
1604
/*
1612
1605
* Cookies are preferred, because initially cookie and get
1613
1606
* variables will be available.
@@ -1619,7 +1612,7 @@ PHPAPI zend_result php_session_start(void)
1619
1612
if (!PS (id )) {
1620
1613
if (PS (use_cookies ) && (data = zend_hash_str_find (& EG (symbol_table ), ZEND_STRL ("_COOKIE" )))) {
1621
1614
ZVAL_DEREF (data );
1622
- if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), lensess ))) {
1615
+ if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_find (Z_ARRVAL_P (data ), PS (session_name )))) {
1623
1616
ppid2sid (ppid );
1624
1617
PS (send_cookie ) = 0 ;
1625
1618
PS (define_sid ) = 0 ;
@@ -1629,13 +1622,13 @@ PHPAPI zend_result php_session_start(void)
1629
1622
if (!PS (use_only_cookies )) {
1630
1623
if (!PS (id ) && (data = zend_hash_str_find (& EG (symbol_table ), ZEND_STRL ("_GET" )))) {
1631
1624
ZVAL_DEREF (data );
1632
- if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), lensess ))) {
1625
+ if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_find (Z_ARRVAL_P (data ), PS (session_name )))) {
1633
1626
ppid2sid (ppid );
1634
1627
}
1635
1628
}
1636
1629
if (!PS (id ) && (data = zend_hash_str_find (& EG (symbol_table ), ZEND_STRL ("_POST" )))) {
1637
1630
ZVAL_DEREF (data );
1638
- if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_str_find (Z_ARRVAL_P (data ), PS (session_name ), lensess ))) {
1631
+ if (Z_TYPE_P (data ) == IS_ARRAY && (ppid = zend_hash_find (Z_ARRVAL_P (data ), PS (session_name )))) {
1639
1632
ppid2sid (ppid );
1640
1633
}
1641
1634
}
@@ -1717,7 +1710,7 @@ static zend_result php_session_reset(void)
1717
1710
PHPAPI void session_adapt_url (const char * url , size_t url_len , char * * new_url , size_t * new_len )
1718
1711
{
1719
1712
if (APPLY_TRANS_SID && (PS (session_status ) == php_session_active )) {
1720
- * new_url = php_url_scanner_adapt_single_url (url , url_len , PS (session_name ), ZSTR_VAL (PS (id )), new_len , 1 );
1713
+ * new_url = php_url_scanner_adapt_single_url (url , url_len , ZSTR_VAL ( PS (session_name )) , ZSTR_VAL (PS (id )), new_len , true );
1721
1714
}
1722
1715
}
1723
1716
@@ -1913,7 +1906,6 @@ PHP_FUNCTION(session_get_cookie_params)
1913
1906
PHP_FUNCTION (session_name )
1914
1907
{
1915
1908
zend_string * name = NULL ;
1916
- zend_string * ini_name ;
1917
1909
1918
1910
if (zend_parse_parameters (ZEND_NUM_ARGS (), "|P!" , & name ) == FAILURE ) {
1919
1911
RETURN_THROWS ();
@@ -1929,10 +1921,10 @@ PHP_FUNCTION(session_name)
1929
1921
RETURN_FALSE ;
1930
1922
}
1931
1923
1932
- RETVAL_STRING ( PS (session_name ));
1924
+ RETVAL_STRINGL ( ZSTR_VAL ( PS (session_name )), ZSTR_LEN ( PS ( session_name ) ));
1933
1925
1934
1926
if (name ) {
1935
- ini_name = ZSTR_INIT_LITERAL ("session.name" , 0 );
1927
+ zend_string * ini_name = ZSTR_INIT_LITERAL ("session.name" , 0 );
1936
1928
zend_alter_ini_entry (ini_name , name , PHP_INI_USER , PHP_INI_STAGE_RUNTIME );
1937
1929
zend_string_release_ex (ini_name , 0 );
1938
1930
}
@@ -2338,7 +2330,7 @@ PHP_FUNCTION(session_regenerate_id)
2338
2330
zend_string_release_ex (PS (id ), 0 );
2339
2331
PS (id ) = NULL ;
2340
2332
2341
- if (PS (mod )-> s_open (& PS (mod_data ), ZSTR_VAL (PS (save_path )), PS (session_name )) == FAILURE ) {
2333
+ if (PS (mod )-> s_open (& PS (mod_data ), ZSTR_VAL (PS (save_path )), ZSTR_VAL ( PS (session_name ) )) == FAILURE ) {
2342
2334
PS (session_status ) = php_session_none ;
2343
2335
if (!EG (exception )) {
2344
2336
zend_throw_error (NULL , "Failed to open session: %s (path: %s)" , PS (mod )-> s_name , ZSTR_VAL (PS (save_path )));
@@ -3021,7 +3013,7 @@ static bool early_find_sid_in(zval *dest, int where, php_session_rfc1867_progres
3021
3013
return 0 ;
3022
3014
}
3023
3015
3024
- if ((ppid = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[where ]), PS (session_name ), progress -> sname_len ))
3016
+ if ((ppid = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[where ]), ZSTR_VAL ( PS (session_name ) ), progress -> sname_len ))
3025
3017
&& Z_TYPE_P (ppid ) == IS_STRING ) {
3026
3018
zval_ptr_dtor (dest );
3027
3019
ZVAL_COPY_DEREF (dest , ppid );
@@ -3129,7 +3121,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_
3129
3121
multipart_event_start * data = (multipart_event_start * ) event_data ;
3130
3122
progress = ecalloc (1 , sizeof (php_session_rfc1867_progress ));
3131
3123
progress -> content_length = data -> content_length ;
3132
- progress -> sname_len = strlen (PS (session_name ));
3124
+ progress -> sname_len = ZSTR_LEN (PS (session_name ));
3133
3125
PS (rfc1867_progress ) = progress ;
3134
3126
}
3135
3127
break ;
@@ -3151,7 +3143,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_
3151
3143
if (data -> name && data -> value && value_len ) {
3152
3144
size_t name_len = strlen (data -> name );
3153
3145
3154
- if (name_len == progress -> sname_len && memcmp ( data -> name , PS (session_name ), name_len ) == 0 ) {
3146
+ if (zend_string_equals_cstr ( PS (session_name ), data -> name , name_len )) {
3155
3147
zval_ptr_dtor (& progress -> sid );
3156
3148
ZVAL_STRINGL (& progress -> sid , (* data -> value ), value_len );
3157
3149
} else if (zend_string_equals_cstr (PS (rfc1867_name ), data -> name , name_len )) {
0 commit comments