@@ -1373,7 +1373,7 @@ check_file:;
13731373 return phar_create_or_parse_filename (fname , alias , is_data , options , pphar , error );
13741374}
13751375
1376- static zend_result phar_open_from_fp (php_stream * fp , const char * fname , size_t fname_len , const char * alias , size_t alias_len , uint32_t options , phar_archive_data * * pphar , char * * error );
1376+ static zend_result phar_open_from_fp (php_stream * fp , const char * fname , size_t fname_len , /* copyable & hash update */ zend_string * alias , uint32_t options , phar_archive_data * * pphar , char * * error );
13771377
13781378ZEND_ATTRIBUTE_NONNULL_ARGS (1 , 5 , 6 ) zend_result phar_create_or_parse_filename (
13791379 zend_string * fname ,
@@ -1399,10 +1399,8 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5, 6) zend_result phar_create_or_parse_filename(
13991399 fname = actual ;
14001400 }
14011401
1402- const char * alias_cstr = alias ? ZSTR_VAL (alias ) : NULL ;
1403- size_t alias_len = alias ? ZSTR_LEN (alias ) : 0 ;
14041402 if (fp ) {
1405- if (phar_open_from_fp (fp , ZSTR_VAL (fname ), ZSTR_LEN (fname ), alias_cstr , alias_len , options , pphar , error ) == SUCCESS ) {
1403+ if (phar_open_from_fp (fp , ZSTR_VAL (fname ), ZSTR_LEN (fname ), alias , options , pphar , error ) == SUCCESS ) {
14061404 if ((* pphar )-> is_data || !PHAR_G (readonly )) {
14071405 (* pphar )-> is_writeable = 1 ;
14081406 }
@@ -1520,8 +1518,14 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 5, 6) zend_result phar_create_or_parse_filename(
15201518 * that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS
15211519 * or FAILURE is returned and pphar is set to a pointer to the phar's manifest
15221520 */
1523- zend_result phar_open_from_filename (char * fname , size_t fname_len , const zend_string * alias , uint32_t options , phar_archive_data * * pphar , char * * error ) /* {{{ */
1524- {
1521+ zend_result phar_open_from_filename (
1522+ char * fname ,
1523+ size_t fname_len ,
1524+ /* copyable & hash update */ zend_string * alias ,
1525+ uint32_t options ,
1526+ phar_archive_data * * pphar ,
1527+ char * * error
1528+ ) {
15251529 php_stream * fp ;
15261530 zend_string * actual ;
15271531 bool is_data = false;
@@ -1564,23 +1568,29 @@ zend_result phar_open_from_filename(char *fname, size_t fname_len, const zend_st
15641568 fname_len = ZSTR_LEN (actual );
15651569 }
15661570
1567- zend_result ret = phar_open_from_fp (fp , fname , fname_len , alias_cstr , alias_len , options , pphar , error );
1571+ zend_result ret = phar_open_from_fp (fp , fname , fname_len , alias , options , pphar , error );
15681572
15691573 if (actual ) {
15701574 zend_string_release_ex (actual , 0 );
15711575 }
15721576
15731577 return ret ;
15741578}
1575- /* }}}*/
15761579
15771580/**
15781581 * Scan an open fp for the required __HALT_COMPILER(); ?> token and verify
15791582 * that the manifest is proper, then pass it to phar_parse_pharfile(). SUCCESS
15801583 * or FAILURE is returned and pphar is set to a pointer to the phar's manifest
15811584 */
1582- static zend_result phar_open_from_fp (php_stream * fp , const char * fname , size_t fname_len , const char * alias , size_t alias_len , uint32_t options , phar_archive_data * * pphar , char * * error ) /* {{{ */
1583- {
1585+ static zend_result phar_open_from_fp (
1586+ php_stream * fp ,
1587+ const char * fname ,
1588+ size_t fname_len ,
1589+ /* copyable & hash update */ zend_string * alias ,
1590+ uint32_t options ,
1591+ phar_archive_data * * pphar ,
1592+ char * * error
1593+ ) {
15841594 static const char token [] = "__HALT_COMPILER();" ;
15851595 static const char zip_magic [] = "PK\x03\x04" ;
15861596 static const char gz_magic [] = "\x1f\x8b\x08" ;
@@ -1731,20 +1741,22 @@ static zend_result phar_open_from_fp(php_stream* fp, const char *fname, size_t f
17311741
17321742 if (!memcmp (pos , zip_magic , 4 )) {
17331743 php_stream_seek (fp , 0 , SEEK_END );
1734- return phar_parse_zipfile (fp , fname , fname_len , alias , alias_len , pphar , error );
1744+ return phar_parse_zipfile (fp , fname , fname_len , alias , pphar , error );
17351745 }
17361746
17371747 if (got >= 512 ) {
17381748 if (phar_is_tar (pos , fname )) {
17391749 php_stream_rewind (fp );
1740- return phar_parse_tarfile (fp , fname , fname_len , alias , alias_len , pphar , compression , error );
1750+ return phar_parse_tarfile (fp , fname , fname_len , alias , pphar , compression , error );
17411751 }
17421752 }
17431753 }
17441754
17451755 if (got > 0 && (pos = php_memnistr (buffer , token , tokenlen , buffer + got + sizeof (token ))) != NULL ) {
17461756 halt_offset += (pos - buffer ); /* no -tokenlen+tokenlen here */
1747- return phar_parse_pharfile (fp , fname , fname_len , alias , alias_len , halt_offset , pphar , compression , error );
1757+ const char * alias_cstr = alias ? ZSTR_VAL (alias ) : NULL ;
1758+ size_t alias_len = alias ? ZSTR_LEN (alias ) : 0 ;
1759+ return phar_parse_pharfile (fp , fname , fname_len , alias_cstr , alias_len , halt_offset , pphar , compression , error );
17481760 }
17491761
17501762 halt_offset += got ;
@@ -1753,7 +1765,6 @@ static zend_result phar_open_from_fp(php_stream* fp, const char *fname, size_t f
17531765
17541766 MAPPHAR_ALLOC_FAIL ("internal corruption of phar \"%s\" (__HALT_COMPILER(); not found)" )
17551767}
1756- /* }}} */
17571768
17581769/*
17591770 * given the location of the file extension and the start of the file path,
@@ -2267,7 +2278,7 @@ zend_string* phar_split_fname(const char *filename, size_t filename_len, zend_st
22672278 * Invoked when a user calls Phar::mapPhar() from within an executing .phar
22682279 * to set up its manifest directly
22692280 */
2270- ZEND_ATTRIBUTE_NONNULL_ARGS (2 ) zend_result phar_open_executed_filename (const zend_string * alias , char * * error ) /* {{{ */
2281+ ZEND_ATTRIBUTE_NONNULL_ARGS (2 ) zend_result phar_open_executed_filename (/* copyable & hash update */ zend_string * alias , char * * error ) /* {{{ */
22712282{
22722283 * error = NULL ;
22732284
@@ -2309,7 +2320,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(2) zend_result phar_open_executed_filename(const zen
23092320 fname = actual ;
23102321 }
23112322
2312- zend_result ret = phar_open_from_fp (fp , ZSTR_VAL (fname ), ZSTR_LEN (fname ), alias_cstr , alias_len , REPORT_ERRORS , NULL , error );
2323+ zend_result ret = phar_open_from_fp (fp , ZSTR_VAL (fname ), ZSTR_LEN (fname ), alias , REPORT_ERRORS , NULL , error );
23132324
23142325 if (actual ) {
23152326 zend_string_release_ex (actual , 0 );
0 commit comments