diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-02-01 14:43:52 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-02-01 14:43:52 +0000 |
commit | 28cd40919d433b0825580bc804fa5321f3e30dfc (patch) | |
tree | cad3ddc8d00dc33b8979682e1f5d041fae0b9e64 | |
parent | 09273098521913a204db5320f763abd7227ebd2e (diff) | |
download | php-git-28cd40919d433b0825580bc804fa5321f3e30dfc.tar.gz |
- Fixed bug #49072 (feof never returns true for damaged file in zip).
-rw-r--r-- | ext/zip/zip_stream.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index dad09233e7..400edd6e6c 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -30,11 +30,11 @@ struct php_zip_stream_data_t { /* {{{ 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 @@ static size_t php_zip_ops_read(php_stream *stream, char *buf, size_t count TSRML 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); } /* }}} */ |