From: Dmitry Stogov Date: Wed, 18 Apr 2007 13:53:32 +0000 (+0000) Subject: Fixed crash X-Git-Tag: RELEASE_1_2_0~283 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98423baf138533bf1e0a178e6db6cfcc429b302e;p=php Fixed crash --- diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index c809db4c2e..420f8a63c7 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -718,8 +718,16 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void return PHP_STREAM_OPTION_RETURN_ERR; } - if (range->length == 0) { - range->length = GetFileSize(hfile, NULL) - range->offset; + size = GetFileSize(hfile, NULL); + if (range->length == 0 && range->offset > 0 && range->offset < size) { + range->length = size - range->offset; + } + if (range->length == 0 || range->length > size) { + range->length = size; + } + if (range->offset >= size) { + range->offset = size; + range->length = 0; } /* figure out how big a chunk to map to be able to view the part that we need */