From 9fecf3eea5dc44bd5d28f7eadc2cd6d93985e52d Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Tue, 31 Oct 2006 19:03:57 +0000 Subject: [PATCH] - fix possible leak in addFile when an unicode filename is given - Mark getStream as Unicode ready, the tests was wrong $unistring .= fread($fpbinary); $unistring remains as unicode. --- ext/zip/php_zip.c | 9 ++++++++- ext/zip/tests/oo_stream.phpt | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 41b827f9ac..356da026ac 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -990,11 +990,18 @@ ZIPARCHIVE_METHOD(addFile) } if(!expand_filepath(filename, resolved_path TSRMLS_CC)) { + if (Z_TYPE_PP(filename_zval) == IS_UNICODE) { + efree(entry_name); + } + RETURN_FALSE; } zs = zip_source_file(intern, resolved_path, 0, 0); if (!zs) { + if (Z_TYPE_PP(filename_zval) == IS_UNICODE) { + efree(entry_name); + } RETURN_FALSE; } @@ -1817,7 +1824,7 @@ ZIPARCHIVE_METHOD(getFromIndex) } /* }}} */ -/* {{{ proto resource getStream(string entryname) +/* {{{ proto resource getStream(string entryname) U get a stream for an entry using its name */ ZIPARCHIVE_METHOD(getStream) { diff --git a/ext/zip/tests/oo_stream.phpt b/ext/zip/tests/oo_stream.phpt index 126e78f6f7..7316f505f9 100644 --- a/ext/zip/tests/oo_stream.phpt +++ b/ext/zip/tests/oo_stream.phpt @@ -18,7 +18,7 @@ $fp = $zip->getStream('foo'); var_dump($fp); if(!$fp) exit("\n"); -$contents = ''; +$contents = b''; while (!feof($fp)) { $contents .= fread($fp, 255); } @@ -32,7 +32,7 @@ $fp = fopen('zip://' . dirname(__FILE__) . '/test_with_comment.zip#foo', 'rb'); if (!$fp) { exit("cannot open\n"); } -$contents = ''; +$contents = b''; while (!feof($fp)) { $contents .= fread($fp, 2); } -- 2.40.0