@@ -102,7 +102,7 @@ zend_class_entry *php_session_update_timestamp_iface_entry;
102102
103103static zend_result php_session_send_cookie (void );
104104static zend_result php_session_abort (void );
105- static void proposed_session_id_to_session_id (zval * proposed_session_id );
105+ static void proposed_session_id_to_session_id (const zval * proposed_session_id );
106106
107107/* Initialized in MINIT, readonly otherwise. */
108108static int my_module_number = 0 ;
@@ -286,7 +286,7 @@ static ZEND_COLD void php_session_cancel_decode(void)
286286 php_error_docref (NULL , E_WARNING , "Failed to decode session object. Session has been destroyed" );
287287}
288288
289- static zend_result php_session_decode (zend_string * data )
289+ static zend_result php_session_decode (const zend_string * data )
290290{
291291 ZEND_ASSERT (PS (serializer ));
292292 zend_result result = SUCCESS ;
@@ -653,17 +653,17 @@ static PHP_INI_MH(OnUpdateSaveDir)
653653
654654 /* Only do the open_basedir check at runtime */
655655 if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS ) {
656- char * p ;
657-
658656 if (memchr (ZSTR_VAL (new_value ), '\0' , ZSTR_LEN (new_value )) != NULL ) {
659657 return FAILURE ;
660658 }
661659
662660 /* we do not use zend_memrchr() since path can contain ; itself */
663- if (( p = strchr (ZSTR_VAL (new_value ), ';' ))) {
664- char * p2 ;
661+ const char * p = strchr (ZSTR_VAL (new_value ), ';' );
662+ if ( p ) {
665663 p ++ ;
666- if ((p2 = strchr (p , ';' ))) {
664+
665+ const char * p2 = strchr (p , ';' );
666+ if (p2 ) {
667667 p = p2 + 1 ;
668668 }
669669 } else {
@@ -1193,7 +1193,7 @@ PHPAPI zend_result php_session_update_timestamp(PS_UPDATE_TIMESTAMP_ARGS) {
11931193 ****************** */
11941194
11951195typedef struct {
1196- char * name ;
1196+ const char * name ;
11971197 void (* func )(void );
11981198} php_session_cache_limiter_t ;
11991199
@@ -1468,8 +1468,6 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name)
14681468
14691469static bool should_invalidate_session_for_external_referer (void )
14701470{
1471- zval * referer_data ;
1472-
14731471 /* No external referer check configured */
14741472 if (!PS (id ) || PS (extern_referer_chk )[0 ] == '\0' ) {
14751473 return false;
@@ -1481,7 +1479,7 @@ static bool should_invalidate_session_for_external_referer(void)
14811479 }
14821480
14831481 /* Get HTTP_REFERER header */
1484- referer_data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), ZEND_STRL ("HTTP_REFERER" ));
1482+ const zval * referer_data = zend_hash_str_find (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ]), ZEND_STRL ("HTTP_REFERER" ));
14851483 if (!referer_data || Z_TYPE_P (referer_data ) != IS_STRING || Z_STRLEN_P (referer_data ) == 0 ) {
14861484 return false;
14871485 }
@@ -1492,7 +1490,7 @@ static bool should_invalidate_session_for_external_referer(void)
14921490
14931491static void try_find_session_id_in_global (const char * global_name , size_t global_name_len )
14941492{
1495- zval * global_data , * potential_session_id ;
1493+ zval * global_data ;
14961494
14971495 if (PS (id )) {
14981496 return ;
@@ -1508,7 +1506,7 @@ static void try_find_session_id_in_global(const char *global_name, size_t global
15081506 return ;
15091507 }
15101508
1511- potential_session_id = zend_hash_find (Z_ARRVAL_P (global_data ), PS (session_name ));
1509+ const zval * potential_session_id = zend_hash_find (Z_ARRVAL_P (global_data ), PS (session_name ));
15121510 if (potential_session_id ) {
15131511 proposed_session_id_to_session_id (potential_session_id );
15141512 }
@@ -1537,7 +1535,7 @@ static bool php_can_change_session_setting(const char *setting_name, bool check_
15371535
15381536static void try_find_session_id_in_cookies (void )
15391537{
1540- zval * cookie_data , * potential_session_id ;
1538+ zval * cookie_data ;
15411539
15421540 if (!PS (use_cookies ) || PS (id )) {
15431541 return ;
@@ -1553,15 +1551,15 @@ static void try_find_session_id_in_cookies(void)
15531551 return ;
15541552 }
15551553
1556- potential_session_id = zend_hash_find (Z_ARRVAL_P (cookie_data ), PS (session_name ));
1554+ const zval * potential_session_id = zend_hash_find (Z_ARRVAL_P (cookie_data ), PS (session_name ));
15571555 if (potential_session_id ) {
15581556 proposed_session_id_to_session_id (potential_session_id );
15591557 PS (send_cookie ) = false;
15601558 PS (define_sid ) = false;
15611559 }
15621560}
15631561
1564- static void proposed_session_id_to_session_id (zval * proposed_session_id ) {
1562+ static void proposed_session_id_to_session_id (const zval * proposed_session_id ) {
15651563 ZVAL_DEREF (proposed_session_id );
15661564 if (Z_TYPE_P (proposed_session_id ) == IS_STRING ) {
15671565 PS (id ) = zend_string_copy (Z_STR_P (proposed_session_id ));
@@ -1654,7 +1652,7 @@ PHPAPI zend_result php_session_reset_id(void)
16541652
16551653PHPAPI zend_result php_session_start (void )
16561654{
1657- char * value ;
1655+ const char * value ;
16581656
16591657 switch (PS (session_status )) {
16601658 case php_session_active :
@@ -2831,18 +2829,14 @@ static zend_result php_rinit_session(bool auto_start)
28312829
28322830 PS (mod ) = NULL ;
28332831 {
2834- char * value ;
2835-
2836- value = zend_ini_string (ZEND_STRL ("session.save_handler" ), false);
2832+ const char * value = zend_ini_string (ZEND_STRL ("session.save_handler" ), false);
28372833 if (value ) {
28382834 PS (mod ) = _php_find_ps_module (value );
28392835 }
28402836 }
28412837
28422838 if (PS (serializer ) == NULL ) {
2843- char * value ;
2844-
2845- value = zend_ini_string (ZEND_STRL ("session.serialize_handler" ), false);
2839+ const char * value = zend_ini_string (ZEND_STRL ("session.serialize_handler" ), false);
28462840 if (value ) {
28472841 PS (serializer ) = _php_find_ps_serializer (value );
28482842 }
@@ -3082,7 +3076,7 @@ static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *pro
30823076 early_find_sid_in (& progress -> sid , TRACK_VARS_GET );
30833077}
30843078
3085- static bool php_check_cancel_upload (php_session_rfc1867_progress * progress )
3079+ static bool php_check_cancel_upload (const php_session_rfc1867_progress * progress )
30863080{
30873081 zval * progress_ary , * cancel_upload ;
30883082
@@ -3132,7 +3126,7 @@ static void php_session_rfc1867_update(php_session_rfc1867_progress *progress, b
31323126 php_session_flush (true);
31333127}
31343128
3135- static void php_session_rfc1867_cleanup (php_session_rfc1867_progress * progress )
3129+ static void php_session_rfc1867_cleanup (const php_session_rfc1867_progress * progress )
31363130{
31373131 php_session_initialize ();
31383132 PS (session_status ) = php_session_active ;
@@ -3160,14 +3154,14 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_
31603154
31613155 switch (event ) {
31623156 case MULTIPART_EVENT_START : {
3163- multipart_event_start * data = ( multipart_event_start * ) event_data ;
3157+ const multipart_event_start * data = event_data ;
31643158 progress = ecalloc (1 , sizeof (php_session_rfc1867_progress ));
31653159 progress -> content_length = data -> content_length ;
31663160 PS (rfc1867_progress ) = progress ;
31673161 }
31683162 break ;
31693163 case MULTIPART_EVENT_FORMDATA : {
3170- multipart_event_formdata * data = ( multipart_event_formdata * ) event_data ;
3164+ const multipart_event_formdata * data = event_data ;
31713165 size_t value_len ;
31723166
31733167 if (Z_TYPE (progress -> sid ) && progress -> key .s ) {
@@ -3200,7 +3194,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_
32003194 }
32013195 break ;
32023196 case MULTIPART_EVENT_FILE_START : {
3203- multipart_event_file_start * data = ( multipart_event_file_start * ) event_data ;
3197+ const multipart_event_file_start * data = event_data ;
32043198
32053199 /* Do nothing when $_POST["PHP_SESSION_UPLOAD_PROGRESS"] is not set
32063200 * or when we have no session id */
@@ -3261,7 +3255,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_
32613255 }
32623256 break ;
32633257 case MULTIPART_EVENT_FILE_DATA : {
3264- multipart_event_file_data * data = ( multipart_event_file_data * ) event_data ;
3258+ const multipart_event_file_data * data = event_data ;
32653259
32663260 if (!Z_TYPE (progress -> sid ) || !progress -> key .s ) {
32673261 break ;
@@ -3274,7 +3268,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_
32743268 }
32753269 break ;
32763270 case MULTIPART_EVENT_FILE_END : {
3277- multipart_event_file_end * data = ( multipart_event_file_end * ) event_data ;
3271+ const multipart_event_file_end * data = event_data ;
32783272
32793273 if (!Z_TYPE (progress -> sid ) || !progress -> key .s ) {
32803274 break ;
@@ -3293,7 +3287,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_
32933287 }
32943288 break ;
32953289 case MULTIPART_EVENT_END : {
3296- multipart_event_end * data = ( multipart_event_end * ) event_data ;
3290+ const multipart_event_end * data = event_data ;
32973291
32983292 if (Z_TYPE (progress -> sid ) && progress -> key .s ) {
32993293 if (PS (rfc1867_cleanup )) {
0 commit comments