From 71c7c383b4a5cb2c13549d5426b9abfc0bed4b7d Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Sun, 7 Jan 2007 19:05:12 +0000 Subject: [PATCH] fix unlink - make sure it actually erases the file --- ext/phar/phar.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 2474adc5e3..fa7a426e4c 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1095,7 +1095,7 @@ php_stream_wrapper php_stream_phar_wrapper = { */ static int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_data *idata, php_uint32 crc32 TSRMLS_DC) /* {{{ */ { - unsigned int crc = ~0; + php_uint32 crc = ~0; int len = idata->internal_file->uncompressed_filesize; char c; @@ -1517,7 +1517,7 @@ static int phar_flush(php_stream *stream TSRMLS_DC) /* {{{ */ off_t manifest_ftell, bufsize; long offset; php_uint32 copy, loc, new_manifest_count; - unsigned int newcrc32; + php_uint32 newcrc32; php_stream *file, *newfile, *compressedfile; php_stream_filter *filter; @@ -2198,6 +2198,7 @@ static int phar_unlink(php_stream_wrapper *wrapper, char *url, int options, php_ php_url *resource; char *internal_file; phar_entry_data *idata; + php_stream *fpf; resource = php_url_parse(url); @@ -2240,6 +2241,10 @@ static int phar_unlink(php_stream_wrapper *wrapper, char *url, int options, php_ } } idata->internal_file->flags |= PHAR_ENT_DELETED; + /* we need to "flush" the stream to save the newly deleted file on disk */ + fpf = php_stream_alloc(&phar_ops, idata, NULL, "wb"); + phar_flush(fpf TSRMLS_CC); + php_stream_close(fpf); efree(idata); efree(internal_file); php_url_free(resource); -- 2.40.0