@@ -354,8 +354,7 @@ static zend_result php_zip_add_file(ze_zip_object *obj, const char *filename, si
354354typedef struct {
355355 zend_long remove_all_path ;
356356 const zend_string * remove_path ;
357- char * add_path ;
358- size_t add_path_len ;
357+ const zend_string * add_path ;
359358 zip_flags_t flags ;
360359 zip_int32_t comp_method ;
361360 zip_uint32_t comp_flags ;
@@ -469,8 +468,7 @@ static zend_result php_zip_parse_options(HashTable *options, zip_options *opts)
469468 zend_value_error ("Option \"add_path\" must be less than %d bytes" , MAXPATHLEN - 1 );
470469 return FAILURE ;
471470 }
472- opts -> add_path_len = Z_STRLEN_P (option );
473- opts -> add_path = Z_STRVAL_P (option );
471+ opts -> add_path = Z_STR_P (option );
474472 }
475473
476474 if ((option = zend_hash_str_find (options , "flags" , sizeof ("flags" ) - 1 )) != NULL ) {
@@ -1849,16 +1847,16 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
18491847 }
18501848
18511849 if (opts .add_path ) {
1852- if ((opts .add_path_len + file_stripped_len ) > MAXPATHLEN ) {
1850+ if ((ZSTR_LEN ( opts .add_path ) + file_stripped_len ) > MAXPATHLEN ) {
18531851 if (basename ) {
18541852 zend_string_release_ex (basename , false);
18551853 }
1856- php_error_docref (NULL , E_WARNING , "Entry name too long (max: %d, %zd given)" ,
1857- MAXPATHLEN - 1 , (opts .add_path_len + file_stripped_len ));
1854+ php_error_docref (NULL , E_WARNING , "Entry name too long (max: %d, %zu given)" ,
1855+ MAXPATHLEN - 1 , (ZSTR_LEN ( opts .add_path ) + file_stripped_len ));
18581856 zend_array_destroy (Z_ARR_P (return_value ));
18591857 RETURN_FALSE ;
18601858 }
1861- snprintf (entry_name_buf , MAXPATHLEN , "%s%s" , opts .add_path , file_stripped );
1859+ snprintf (entry_name_buf , MAXPATHLEN , "%s%s" , ZSTR_VAL ( opts .add_path ) , file_stripped );
18621860 } else {
18631861 snprintf (entry_name_buf , MAXPATHLEN , "%s" , file_stripped );
18641862 }
0 commit comments