@@ -2535,8 +2535,9 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2535
2535
zend_string * newstub ;
2536
2536
phar_entry_info * entry , * newentry ;
2537
2537
size_t halt_offset ;
2538
- int restore_alias_len , global_flags = 0 , closeoldfile ;
2539
- bool has_dirs = 0 ;
2538
+ int restore_alias_len , global_flags = 0 ;
2539
+ bool must_close_old_file = false;
2540
+ bool has_dirs = false;
2540
2541
char manifest [18 ], entry_buffer [24 ];
2541
2542
zend_off_t manifest_ftell ;
2542
2543
zend_long offset ;
@@ -2547,8 +2548,9 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2547
2548
php_stream_filter * filter ;
2548
2549
php_serialize_data_t metadata_hash ;
2549
2550
smart_str main_metadata_str = {0 };
2550
- int free_fp = 1 , free_ufp = 1 ;
2551
- int manifest_hack = 0 ;
2551
+ bool free_fp = true;
2552
+ bool free_ufp = true;
2553
+ bool manifest_hack = false;
2552
2554
php_stream * shared_cfp = NULL ;
2553
2555
2554
2556
if (phar -> is_persistent ) {
@@ -2582,18 +2584,18 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2582
2584
2583
2585
if (phar -> fp && !phar -> is_brandnew ) {
2584
2586
oldfile = phar -> fp ;
2585
- closeoldfile = 0 ;
2587
+ must_close_old_file = false ;
2586
2588
php_stream_rewind (oldfile );
2587
2589
} else {
2588
2590
oldfile = php_stream_open_wrapper (phar -> fname , "rb" , 0 , NULL );
2589
- closeoldfile = oldfile != NULL ;
2591
+ must_close_old_file = oldfile != NULL ;
2590
2592
}
2591
2593
newfile = php_stream_fopen_tmpfile ();
2592
2594
if (!newfile ) {
2593
2595
if (error ) {
2594
2596
spprintf (error , 0 , "unable to create temporary file" );
2595
2597
}
2596
- if (closeoldfile ) {
2598
+ if (must_close_old_file ) {
2597
2599
php_stream_close (oldfile );
2598
2600
}
2599
2601
return EOF ;
@@ -2603,7 +2605,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2603
2605
char * pos = php_stristr (ZSTR_VAL (user_stub ), halt_stub , ZSTR_LEN (user_stub ), strlen (halt_stub ));
2604
2606
2605
2607
if (pos == NULL ) {
2606
- if (closeoldfile ) {
2608
+ if (must_close_old_file ) {
2607
2609
php_stream_close (oldfile );
2608
2610
}
2609
2611
php_stream_close (newfile );
@@ -2621,7 +2623,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2621
2623
len != php_stream_write (newfile , ZSTR_VAL (user_stub ), len )
2622
2624
|| end_sequence_len != php_stream_write (newfile , end_sequence , end_sequence_len )
2623
2625
) {
2624
- if (closeoldfile ) {
2626
+ if (must_close_old_file ) {
2625
2627
php_stream_close (oldfile );
2626
2628
}
2627
2629
php_stream_close (newfile );
@@ -2644,7 +2646,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2644
2646
written = php_stream_write (newfile , ZSTR_VAL (newstub ), phar -> halt_offset );
2645
2647
}
2646
2648
if (phar -> halt_offset != written ) {
2647
- if (closeoldfile ) {
2649
+ if (must_close_old_file ) {
2648
2650
php_stream_close (oldfile );
2649
2651
}
2650
2652
php_stream_close (newfile );
@@ -2697,10 +2699,10 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2697
2699
/* open file pointers refer to this fp, do not free the stream */
2698
2700
switch (entry -> fp_type ) {
2699
2701
case PHAR_FP :
2700
- free_fp = 0 ;
2702
+ free_fp = false ;
2701
2703
break ;
2702
2704
case PHAR_UFP :
2703
- free_ufp = 0 ;
2705
+ free_ufp = false ;
2704
2706
default :
2705
2707
break ;
2706
2708
}
@@ -2711,7 +2713,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2711
2713
2712
2714
if (entry -> is_dir ) {
2713
2715
/* we use this to calculate API version, 1.1.1 is used for phars with directories */
2714
- has_dirs = 1 ;
2716
+ has_dirs = true ;
2715
2717
}
2716
2718
if (!Z_ISUNDEF (entry -> metadata_tracker .val ) && !entry -> metadata_tracker .str ) {
2717
2719
ZEND_ASSERT (!entry -> is_persistent );
@@ -2747,7 +2749,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2747
2749
}
2748
2750
file = phar_get_efp (entry , 0 );
2749
2751
if (-1 == phar_seek_efp (entry , 0 , SEEK_SET , 0 , 1 )) {
2750
- if (closeoldfile ) {
2752
+ if (must_close_old_file ) {
2751
2753
php_stream_close (oldfile );
2752
2754
}
2753
2755
php_stream_close (newfile );
@@ -2767,7 +2769,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2767
2769
}
2768
2770
filter = php_stream_filter_create (phar_compress_filter (entry , 0 ), NULL , 0 );
2769
2771
if (!filter ) {
2770
- if (closeoldfile ) {
2772
+ if (must_close_old_file ) {
2771
2773
php_stream_close (oldfile );
2772
2774
}
2773
2775
php_stream_close (newfile );
@@ -2794,7 +2796,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2794
2796
if (error ) {
2795
2797
spprintf (error , 0 , "unable to create temporary file" );
2796
2798
}
2797
- if (closeoldfile ) {
2799
+ if (must_close_old_file ) {
2798
2800
php_stream_close (oldfile );
2799
2801
}
2800
2802
php_stream_close (newfile );
@@ -2805,7 +2807,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2805
2807
entry -> header_offset = php_stream_tell (entry -> cfp );
2806
2808
php_stream_flush (file );
2807
2809
if (-1 == phar_seek_efp (entry , 0 , SEEK_SET , 0 , 0 )) {
2808
- if (closeoldfile ) {
2810
+ if (must_close_old_file ) {
2809
2811
php_stream_close (oldfile );
2810
2812
}
2811
2813
php_stream_close (newfile );
@@ -2816,7 +2818,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2816
2818
}
2817
2819
php_stream_filter_append ((& entry -> cfp -> writefilters ), filter );
2818
2820
if (SUCCESS != php_stream_copy_to_stream_ex (file , entry -> cfp , entry -> uncompressed_filesize , NULL )) {
2819
- if (closeoldfile ) {
2821
+ if (must_close_old_file ) {
2820
2822
php_stream_close (oldfile );
2821
2823
}
2822
2824
php_stream_close (newfile );
@@ -2858,7 +2860,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2858
2860
if (manifest [0 ] == '\r' || manifest [0 ] == '\n' ) {
2859
2861
manifest_len ++ ;
2860
2862
phar_set_32 (manifest , manifest_len );
2861
- manifest_hack = 1 ;
2863
+ manifest_hack = true ;
2862
2864
}
2863
2865
phar_set_32 (manifest + 4 , new_manifest_count );
2864
2866
if (has_dirs ) {
@@ -2875,7 +2877,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2875
2877
if (sizeof (manifest ) != php_stream_write (newfile , manifest , sizeof (manifest ))
2876
2878
|| (size_t )phar -> alias_len != php_stream_write (newfile , phar -> alias , phar -> alias_len )) {
2877
2879
2878
- if (closeoldfile ) {
2880
+ if (must_close_old_file ) {
2879
2881
php_stream_close (oldfile );
2880
2882
}
2881
2883
@@ -2896,7 +2898,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2896
2898
&& ZSTR_LEN (main_metadata_str .s ) != php_stream_write (newfile , ZSTR_VAL (main_metadata_str .s ), ZSTR_LEN (main_metadata_str .s )))) {
2897
2899
smart_str_free (& main_metadata_str );
2898
2900
2899
- if (closeoldfile ) {
2901
+ if (must_close_old_file ) {
2900
2902
php_stream_close (oldfile );
2901
2903
}
2902
2904
@@ -2932,7 +2934,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2932
2934
if (4 != php_stream_write (newfile , entry_buffer , 4 )
2933
2935
|| entry -> filename_len != php_stream_write (newfile , entry -> filename , entry -> filename_len )
2934
2936
|| (entry -> is_dir && 1 != php_stream_write (newfile , "/" , 1 ))) {
2935
- if (closeoldfile ) {
2937
+ if (must_close_old_file ) {
2936
2938
php_stream_close (oldfile );
2937
2939
}
2938
2940
php_stream_close (newfile );
@@ -2967,7 +2969,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2967
2969
if (sizeof (entry_buffer ) != php_stream_write (newfile , entry_buffer , sizeof (entry_buffer ))
2968
2970
|| (metadata_str &&
2969
2971
ZSTR_LEN (metadata_str ) != php_stream_write (newfile , ZSTR_VAL (metadata_str ), ZSTR_LEN (metadata_str )))) {
2970
- if (closeoldfile ) {
2972
+ if (must_close_old_file ) {
2971
2973
php_stream_close (oldfile );
2972
2974
}
2973
2975
@@ -2981,9 +2983,9 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
2981
2983
}
2982
2984
} ZEND_HASH_FOREACH_END ();
2983
2985
/* Hack - see bug #65028, add padding byte to the end of the manifest */
2984
- if (manifest_hack ) {
2986
+ if (manifest_hack ) {
2985
2987
if (1 != php_stream_write (newfile , manifest , 1 )) {
2986
- if (closeoldfile ) {
2988
+ if (must_close_old_file ) {
2987
2989
php_stream_close (oldfile );
2988
2990
}
2989
2991
@@ -3010,7 +3012,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
3010
3012
} else {
3011
3013
file = phar_get_efp (entry , 0 );
3012
3014
if (-1 == phar_seek_efp (entry , 0 , SEEK_SET , 0 , 0 )) {
3013
- if (closeoldfile ) {
3015
+ if (must_close_old_file ) {
3014
3016
php_stream_close (oldfile );
3015
3017
}
3016
3018
php_stream_close (newfile );
@@ -3022,7 +3024,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
3022
3024
}
3023
3025
3024
3026
if (!file ) {
3025
- if (closeoldfile ) {
3027
+ if (must_close_old_file ) {
3026
3028
php_stream_close (oldfile );
3027
3029
}
3028
3030
php_stream_close (newfile );
@@ -3036,7 +3038,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
3036
3038
entry -> offset = entry -> offset_abs = offset ;
3037
3039
offset += entry -> compressed_filesize ;
3038
3040
if (php_stream_copy_to_stream_ex (file , newfile , entry -> compressed_filesize , & wrote ) == FAILURE ) {
3039
- if (closeoldfile ) {
3041
+ if (must_close_old_file ) {
3040
3042
php_stream_close (oldfile );
3041
3043
}
3042
3044
@@ -3099,7 +3101,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
3099
3101
if (digest ) {
3100
3102
efree (digest );
3101
3103
}
3102
- if (closeoldfile ) {
3104
+ if (must_close_old_file ) {
3103
3105
php_stream_close (oldfile );
3104
3106
}
3105
3107
php_stream_close (newfile );
@@ -3136,7 +3138,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau
3136
3138
phar -> ufp = NULL ;
3137
3139
}
3138
3140
3139
- if (closeoldfile ) {
3141
+ if (must_close_old_file ) {
3140
3142
php_stream_close (oldfile );
3141
3143
}
3142
3144
0 commit comments