[PHP-CVS] svn: /php/php-src/trunk/ext/zip/ zip_stream.c

2011-02-01 Thread Gustavo André dos Santos Lopes
cataphract   Tue, 01 Feb 2011 14:43:52 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=307916

Log:
- Fixed bug #49072 (feof never returns true for damaged file in zip).

Bug: http://bugs.php.net/49072 (Re-Opened) feof never returns true for damaged 
file in zip
  
Changed paths:
U   php/php-src/trunk/ext/zip/zip_stream.c

Modified: php/php-src/trunk/ext/zip/zip_stream.c
===
--- php/php-src/trunk/ext/zip/zip_stream.c  2011-02-01 14:01:00 UTC (rev 
307915)
+++ php/php-src/trunk/ext/zip/zip_stream.c  2011-02-01 14:43:52 UTC (rev 
307916)
@@ -30,11 +30,11 @@
 /* {{{ php_zip_ops_read */
 static size_t php_zip_ops_read(php_stream *stream, char *buf, size_t count 
TSRMLS_DC)
 {
-   size_t n = 0;
+   ssize_t n = 0;
STREAM_DATA_FROM_STREAM();

if (self-za  self-zf) {
-   n = (size_t)zip_fread(self-zf, buf, (int)count);
+   n = zip_fread(self-zf, buf, count);
if (n  0) {
int ze, se;
zip_file_error_get(self-zf, ze, se);
@@ -42,13 +42,15 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING, Zip stream 
error: %s, zip_file_strerror(self-zf));
return 0;
}
-   if (n == 0 || n  count) {
+   /* cast count to signed value to avoid possibly negative n
+* being cast to unsigned value */
+   if (n == 0 || n  (ssize_t)count) {
stream-eof = 1;
} else {
self-cursor += n;
}
}
-   return (n  1 ? 0 : n);
+   return (n  1 ? 0 : (size_t)n);
 }
 /* }}} */


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/ext/zip/ zip_stream.c

2009-08-11 Thread Pierre-Alain Joye
pajoye   Tue, 11 Aug 2009 17:19:35 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=287104

Log:
- destroy the file entry stream first

Changed paths:
U   php/php-src/trunk/ext/zip/zip_stream.c

Modified: php/php-src/trunk/ext/zip/zip_stream.c
===
--- php/php-src/trunk/ext/zip/zip_stream.c  2009-08-11 17:15:24 UTC (rev 
287103)
+++ php/php-src/trunk/ext/zip/zip_stream.c  2009-08-11 17:19:35 UTC (rev 
287104)
@@ -68,14 +68,14 @@
 {
STREAM_DATA_FROM_STREAM();
if (close_handle) {
+   if (self-zf) {
+   zip_fclose(self-zf);
+   self-zf = NULL;
+   }
if (self-za) {
zip_close(self-za);
self-za = NULL;
}
-   if (self-zf) {
-   zip_fclose(self-zf);
-   self-zf = NULL;
-   }
}
efree(self);
stream-abstract = NULL;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php