]> granicus.if.org Git - php/commitdiff
- fix possible leak in addFile when an unicode filename is given
authorPierre Joye <pajoye@php.net>
Tue, 31 Oct 2006 19:03:57 +0000 (19:03 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 31 Oct 2006 19:03:57 +0000 (19:03 +0000)
- Mark getStream as Unicode ready, the tests was wrong
  $unistring .= fread($fpbinary); $unistring remains as unicode.

ext/zip/php_zip.c
ext/zip/tests/oo_stream.phpt

index 41b827f9ace5f2c4428b1fc579987e53c1e486df..356da026acfb9a63e7529a4c129ce9107af170d0 100644 (file)
@@ -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)
 {
index 126e78f6f7f53a05eef007cf928fa6015aaa0840..7316f505f9b515d39edec875eea75a3f6ca57422 100644 (file)
@@ -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);
 }