@@ -186,13 +186,12 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
186186 return NULL ;
187187 }
188188
189- size_t host_len = ZSTR_LEN (resource -> host );
190189 phar_request_initialize ();
191190
192191 /* strip leading "/" */
193192 internal_file = estrndup (ZSTR_VAL (resource -> path ) + 1 , ZSTR_LEN (resource -> path ) - 1 );
194193 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 ))) {
196195 if (error ) {
197196 php_stream_wrapper_log_error (wrapper , options , "%s" , error );
198197 efree (error );
@@ -236,14 +235,14 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
236235 } else {
237236 if (!* internal_file && (options & STREAM_OPEN_FOR_INCLUDE )) {
238237 /* 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 )) {
240239 php_stream_wrapper_log_error (wrapper , options , "file %s is not a valid phar archive" , ZSTR_VAL (resource -> host ));
241240 efree (internal_file );
242241 php_url_free (resource );
243242 return NULL ;
244243 }
245244 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 ) {
247246 goto idata_error ;
248247 }
249248 efree (internal_file );
@@ -292,7 +291,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
292291 }
293292 }
294293 /* 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 ) {
296295idata_error :
297296 if (error ) {
298297 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
580579 return FAILURE ;
581580 }
582581
583- size_t host_len = ZSTR_LEN (resource -> host );
584582 phar_request_initialize ();
585583
586584 internal_file = ZSTR_VAL (resource -> path ) + 1 ; /* strip leading "/" */
587585 /* 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 )) {
589587 php_url_free (resource );
590588 if (error ) {
591589 efree (error );
@@ -690,7 +688,6 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
690688 return 0 ;
691689 }
692690
693- size_t host_len = ZSTR_LEN (resource -> host );
694691 phar_request_initialize ();
695692
696693 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
703700 /* need to copy to strip leading "/", will get touched again */
704701 internal_file = estrndup (ZSTR_VAL (resource -> path ) + 1 , ZSTR_LEN (resource -> path ) - 1 );
705702 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 )) {
707704 /* constraints of fp refcount were not met */
708705 if (error ) {
709706 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
818815 return 0 ;
819816 }
820817
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 )) {
824819 php_url_free (resource_from );
825820 php_url_free (resource_to );
826821 php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
0 commit comments