@@ -741,7 +741,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
741741}
742742/* }}} */
743743
744- static int phar_wrapper_rename (php_stream_wrapper * wrapper , const char * url_from , const char * url_to , int options , php_stream_context * context ) /* {{{ */
744+ static bool phar_wrapper_rename (php_stream_wrapper * wrapper , const zend_string * url_from , const zend_string * url_to , int options , php_stream_context * context ) /* {{{ */
745745{
746746 php_url * resource_from , * resource_to ;
747747 char * error ;
@@ -753,8 +753,8 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
753753
754754 error = NULL ;
755755
756- if ((resource_from = phar_parse_url (wrapper , url_from , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
757- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , url_from , url_to , url_from );
756+ if ((resource_from = phar_parse_url (wrapper , ZSTR_VAL ( url_from ) , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
757+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_from ) );
758758 return 0 ;
759759 }
760760 if (SUCCESS != phar_get_archive (& pfrom , ZSTR_VAL (resource_from -> host ), ZSTR_LEN (resource_from -> host ), NULL , 0 , & error )) {
@@ -769,9 +769,9 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
769769 return 0 ;
770770 }
771771
772- if ((resource_to = phar_parse_url (wrapper , url_to , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
772+ if ((resource_to = phar_parse_url (wrapper , ZSTR_VAL ( url_to ) , "wb" , options |PHP_STREAM_URL_STAT_QUIET )) == NULL ) {
773773 php_url_free (resource_from );
774- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , url_from , url_to , url_to );
774+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid or non-writable url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_to ) );
775775 return 0 ;
776776 }
777777 if (SUCCESS != phar_get_archive (& pto , ZSTR_VAL (resource_to -> host ), ZSTR_LEN (resource_to -> host ), NULL , 0 , & error )) {
@@ -790,36 +790,36 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
790790 if (!zend_string_equals (resource_from -> host , resource_to -> host )) {
791791 php_url_free (resource_from );
792792 php_url_free (resource_to );
793- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive" , url_from , url_to );
793+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
794794 return 0 ;
795795 }
796796
797797 /* we must have at the very least phar://alias.phar/internalfile.php */
798798 if (!resource_from -> scheme || !resource_from -> host || !resource_from -> path ) {
799799 php_url_free (resource_from );
800800 php_url_free (resource_to );
801- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , url_from , url_to , url_from );
801+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_from ) );
802802 return 0 ;
803803 }
804804
805805 if (!resource_to -> scheme || !resource_to -> host || !resource_to -> path ) {
806806 php_url_free (resource_from );
807807 php_url_free (resource_to );
808- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , url_from , url_to , url_to );
808+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": invalid url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_to ) );
809809 return 0 ;
810810 }
811811
812812 if (!zend_string_equals_literal_ci (resource_from -> scheme , "phar" )) {
813813 php_url_free (resource_from );
814814 php_url_free (resource_to );
815- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , url_from , url_to , url_from );
815+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_from ) );
816816 return 0 ;
817817 }
818818
819819 if (!zend_string_equals_literal_ci (resource_to -> scheme , "phar" )) {
820820 php_url_free (resource_from );
821821 php_url_free (resource_to );
822- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , url_from , url_to , url_to );
822+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": not a phar stream url \"%s\"" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ), ZSTR_VAL ( url_to ) );
823823 return 0 ;
824824 }
825825
@@ -828,15 +828,15 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
828828 if (SUCCESS != phar_get_archive (& phar , ZSTR_VAL (resource_from -> host ), host_len , NULL , 0 , & error )) {
829829 php_url_free (resource_from );
830830 php_url_free (resource_to );
831- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
831+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) , error );
832832 efree (error );
833833 return 0 ;
834834 }
835835
836836 if (phar -> is_persistent && FAILURE == phar_copy_on_write (& phar )) {
837837 php_url_free (resource_from );
838838 php_url_free (resource_to );
839- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": could not make cached phar writeable" , url_from , url_to );
839+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": could not make cached phar writeable" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
840840 return 0 ;
841841 }
842842
@@ -847,7 +847,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
847847 if (entry -> is_deleted ) {
848848 php_url_free (resource_from );
849849 php_url_free (resource_to );
850- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source has been deleted" , url_from , url_to );
850+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source has been deleted" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
851851 return 0 ;
852852 }
853853 /* transfer all data over to the new entry */
@@ -867,7 +867,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
867867 if (FAILURE == phar_copy_entry_fp (source , entry , & error )) {
868868 php_url_free (resource_from );
869869 php_url_free (resource_to );
870- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
870+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) , error );
871871 efree (error );
872872 zend_hash_str_del (& (phar -> manifest ), entry -> filename , strlen (entry -> filename ));
873873 return 0 ;
@@ -882,7 +882,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
882882 /* file does not exist */
883883 php_url_free (resource_from );
884884 php_url_free (resource_to );
885- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does not exist" , url_from , url_to );
885+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive, source does not exist" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) );
886886 return 0 ;
887887
888888 }
@@ -963,7 +963,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
963963 if (error ) {
964964 php_url_free (resource_from );
965965 php_url_free (resource_to );
966- php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , url_from , url_to , error );
966+ php_error_docref (NULL , E_WARNING , "phar error: cannot rename \"%s\" to \"%s\": %s" , ZSTR_VAL ( url_from ), ZSTR_VAL ( url_to ) , error );
967967 efree (error );
968968 return 0 ;
969969 }
0 commit comments