From: Ilia Alshanetsky Date: Tue, 2 Jan 2007 14:40:32 +0000 (+0000) Subject: Added length parameter validator to zip_entry_read() X-Git-Tag: php-4.4.5RC1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ed521bc6d762ce75cb41e0206260e22f08df9b3;p=php Added length parameter validator to zip_entry_read() --- 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);