@@ -186,13 +186,12 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
186
186
return NULL ;
187
187
}
188
188
189
- size_t host_len = ZSTR_LEN (resource -> host );
190
189
phar_request_initialize ();
191
190
192
191
/* strip leading "/" */
193
192
internal_file = estrndup (ZSTR_VAL (resource -> path ) + 1 , ZSTR_LEN (resource -> path ) - 1 );
194
193
if (mode [0 ] == 'w' || (mode [0 ] == 'r' && mode [1 ] == '+' )) {
195
- if (NULL == (idata = phar_get_or_create_entry_data (ZSTR_VAL (resource -> host ), host_len , internal_file , strlen (internal_file ), mode , 0 , & error , 1 ))) {
194
+ if (NULL == (idata = phar_get_or_create_entry_data (ZSTR_VAL (resource -> host ), ZSTR_LEN ( resource -> host ) , internal_file , strlen (internal_file ), mode , 0 , & error , 1 ))) {
196
195
if (error ) {
197
196
php_stream_wrapper_log_error (wrapper , options , "%s" , error );
198
197
efree (error );
@@ -236,14 +235,14 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
236
235
} else {
237
236
if (!* internal_file && (options & STREAM_OPEN_FOR_INCLUDE )) {
238
237
/* retrieve the stub */
239
- if (FAILURE == phar_get_archive (& phar , ZSTR_VAL (resource -> host ), host_len , NULL , 0 , NULL )) {
238
+ if (FAILURE == phar_get_archive (& phar , ZSTR_VAL (resource -> host ), ZSTR_LEN ( resource -> host ) , NULL , 0 , NULL )) {
240
239
php_stream_wrapper_log_error (wrapper , options , "file %s is not a valid phar archive" , ZSTR_VAL (resource -> host ));
241
240
efree (internal_file );
242
241
php_url_free (resource );
243
242
return NULL ;
244
243
}
245
244
if (phar -> is_tar || phar -> is_zip ) {
246
- if ((FAILURE == phar_get_entry_data (& idata , ZSTR_VAL (resource -> host ), host_len , ".phar/stub.php" , sizeof (".phar/stub.php" )- 1 , "r" , 0 , & error , 0 )) || !idata ) {
245
+ if ((FAILURE == phar_get_entry_data (& idata , ZSTR_VAL (resource -> host ), ZSTR_LEN ( resource -> host ) , ".phar/stub.php" , sizeof (".phar/stub.php" )- 1 , "r" , 0 , & error , 0 )) || !idata ) {
247
246
goto idata_error ;
248
247
}
249
248
efree (internal_file );
@@ -292,7 +291,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
292
291
}
293
292
}
294
293
/* read-only access is allowed to magic files in .phar directory */
295
- if ((FAILURE == phar_get_entry_data (& idata , ZSTR_VAL (resource -> host ), host_len , internal_file , strlen (internal_file ), "r" , 0 , & error , 0 )) || !idata ) {
294
+ if ((FAILURE == phar_get_entry_data (& idata , ZSTR_VAL (resource -> host ), ZSTR_LEN ( resource -> host ) , internal_file , strlen (internal_file ), "r" , 0 , & error , 0 )) || !idata ) {
296
295
idata_error :
297
296
if (error ) {
298
297
php_stream_wrapper_log_error (wrapper , options , "%s" , error );
@@ -580,12 +579,11 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f
580
579
return FAILURE ;
581
580
}
582
581
583
- size_t host_len = ZSTR_LEN (resource -> host );
584
582
phar_request_initialize ();
585
583
586
584
internal_file = ZSTR_VAL (resource -> path ) + 1 ; /* strip leading "/" */
587
585
/* find the phar in our trusty global hash indexed by alias (host of phar://blah.phar/file.whatever) */
588
- if (FAILURE == phar_get_archive (& phar , ZSTR_VAL (resource -> host ), host_len , NULL , 0 , & error )) {
586
+ if (FAILURE == phar_get_archive (& phar , ZSTR_VAL (resource -> host ), ZSTR_LEN ( resource -> host ) , NULL , 0 , & error )) {
589
587
php_url_free (resource );
590
588
if (error ) {
591
589
efree (error );
@@ -690,7 +688,6 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
690
688
return 0 ;
691
689
}
692
690
693
- size_t host_len = ZSTR_LEN (resource -> host );
694
691
phar_request_initialize ();
695
692
696
693
pphar = zend_hash_find_ptr (& (PHAR_G (phar_fname_map )), resource -> host );
@@ -703,7 +700,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
703
700
/* need to copy to strip leading "/", will get touched again */
704
701
internal_file = estrndup (ZSTR_VAL (resource -> path ) + 1 , ZSTR_LEN (resource -> path ) - 1 );
705
702
internal_file_len = ZSTR_LEN (resource -> path ) - 1 ;
706
- if (FAILURE == phar_get_entry_data (& idata , ZSTR_VAL (resource -> host ), host_len , internal_file , internal_file_len , "r" , 0 , & error , 1 )) {
703
+ if (FAILURE == phar_get_entry_data (& idata , ZSTR_VAL (resource -> host ), ZSTR_LEN ( resource -> host ) , internal_file , internal_file_len , "r" , 0 , & error , 1 )) {
707
704
/* constraints of fp refcount were not met */
708
705
if (error ) {
709
706
php_stream_wrapper_log_error (wrapper , options , "unlink of \"%s\" failed: %s" , url , error );
@@ -818,9 +815,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
818
815
return 0 ;
819
816
}
820
817
821
- size_t host_len = ZSTR_LEN (resource_from -> host );
822
-
823
- if (SUCCESS != phar_get_archive (& phar , ZSTR_VAL (resource_from -> host ), host_len , NULL , 0 , & error )) {
818
+ if (SUCCESS != phar_get_archive (& phar , ZSTR_VAL (resource_from -> host ), ZSTR_LEN (resource_from -> host ), NULL , 0 , & error )) {
824
819
php_url_free (resource_from );
825
820
php_url_free (resource_to );
826
821
php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
0 commit comments