]> granicus.if.org Git - php/commitdiff
Added length parameter validator to zip_entry_read()
authorIlia Alshanetsky <iliaa@php.net>
Tue, 2 Jan 2007 14:40:32 +0000 (14:40 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 2 Jan 2007 14:40:32 +0000 (14:40 +0000)
ext/zip/zip.c

index 7cff07f21fe9886626e1fd4f9f2b3d3f01ce4ab7..4b6a828cd43b1d92a7b4637281066a62b0471bc7 100644 (file)
@@ -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);