summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-01-02 14:40:32 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-01-02 14:40:32 +0000
commit5ed521bc6d762ce75cb41e0206260e22f08df9b3 (patch)
tree7b19b6987b10b56d15dc2f0cb7e2b2ff71f573fc
parentc8123f93f0ff6c6ed827e0bbb901cc501995cd18 (diff)
downloadphp-git-5ed521bc6d762ce75cb41e0206260e22f08df9b3.tar.gz
Added length parameter validator to zip_entry_read()
-rw-r--r--ext/zip/zip.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/zip/zip.c b/ext/zip/zip.c
index 7cff07f21f..4b6a828cd4 100644
--- a/ext/zip/zip.c
+++ b/ext/zip/zip.c
@@ -283,7 +283,7 @@ PHP_FUNCTION(zip_entry_open)
}
/* }}} */
-/* {{{ proto string zip_entry_read(resource zip_ent)
+/* {{{ proto string zip_entry_read(resource zip_ent [, int nbytes])
Read X bytes from an opened zip entry */
PHP_FUNCTION(zip_entry_read)
{
@@ -296,6 +296,10 @@ PHP_FUNCTION(zip_entry_read)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zzip_ent, &len) == FAILURE) {
return;
}
+ if (len <= 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The bytes parameter must greater then zero");
+ RETURN_FALSE;
+ }
ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, &zzip_ent, -1, le_zip_entry_name, le_zip_entry);
buf = emalloc(len + 1);