@@ -383,7 +383,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
383
383
php_stream_seek (fp , loc + PHAR_GET_16 (zipentry .extra_len ), SEEK_SET );
384
384
}
385
385
386
- switch (zipentry .compressed ) {
386
+ switch (PHAR_GET_16 ( zipentry .compressed ) ) {
387
387
case PHAR_ZIP_COMP_NONE :
388
388
/* compression flag already set */
389
389
break ;
@@ -450,7 +450,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
450
450
}
451
451
452
452
p = buf ;
453
- entry .metadata_len = zipentry .comment_len ;
453
+ entry .metadata_len = PHAR_GET_16 ( zipentry .comment_len ) ;
454
454
455
455
if (phar_parse_metadata (& p , & (entry .metadata ), PHAR_GET_16 (zipentry .comment_len ) TSRMLS_CC ) == FAILURE ) {
456
456
entry .metadata_len = 0 ;
@@ -997,6 +997,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
997
997
char * temperr = NULL ;
998
998
struct _phar_zip_pass pass ;
999
999
phar_zip_dir_end eocd ;
1000
+ php_uint32 cdir_size , cdir_offset ;
1000
1001
1001
1002
pass .error = & temperr ;
1002
1003
entry .flags = PHAR_ENT_PERM_DEF_FILE ;
@@ -1198,7 +1199,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
1198
1199
memset (& eocd , 0 , sizeof (eocd ));
1199
1200
1200
1201
strncpy (eocd .signature , "PK\5\6" , 4 );
1201
- eocd .counthere = eocd .count = zend_hash_num_elements (& phar -> manifest );
1202
+ eocd .counthere = eocd .count = PHAR_GET_16 ( zend_hash_num_elements (& phar -> manifest ) );
1202
1203
zend_hash_apply_with_argument (& phar -> manifest , phar_zip_changed_apply , (void * ) & pass TSRMLS_CC );
1203
1204
1204
1205
if (temperr ) {
@@ -1217,11 +1218,13 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
1217
1218
}
1218
1219
1219
1220
/* save zip */
1220
- eocd .cdir_size = php_stream_tell (pass .centralfp );
1221
- eocd .cdir_offset = php_stream_tell (pass .filefp );
1221
+ cdir_size = php_stream_tell (pass .centralfp );
1222
+ cdir_offset = php_stream_tell (pass .filefp );
1223
+ eocd .cdir_size = PHAR_SET_32 (cdir_size );
1224
+ eocd .cdir_offset = PHAR_SET_32 (cdir_offset );
1222
1225
php_stream_seek (pass .centralfp , 0 , SEEK_SET );
1223
1226
1224
- if (eocd . cdir_size != php_stream_copy_to_stream (pass .centralfp , pass .filefp , PHP_STREAM_COPY_ALL )) {
1227
+ if (cdir_size != php_stream_copy_to_stream (pass .centralfp , pass .filefp , PHP_STREAM_COPY_ALL )) {
1225
1228
if (error ) {
1226
1229
spprintf (error , 4096 , "phar zip flush of \"%s\" failed: unable to write central-directory" , phar -> fname );
1227
1230
}
0 commit comments