summaryrefslogtreecommitdiff
path: root/main/streams
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-17 15:58:29 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-17 15:58:29 +0200
commitb864abfe23fde5d79a303519674ba83062f89361 (patch)
tree28b5541853c9df1801431a20ba22d5007ad63175 /main/streams
parentbd0514913b7f803858b062919af22ac16fe5cacc (diff)
downloadphp-git-b864abfe23fde5d79a303519674ba83062f89361.tar.gz
Fixed bug #69100
Diffstat (limited to 'main/streams')
-rw-r--r--main/streams/plain_wrapper.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index d409fe99f0..837485742a 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -696,18 +696,15 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
case PHP_STREAM_MMAP_MAP_RANGE:
- if(do_fstat(data, 1) != 0) {
+ if (do_fstat(data, 1) != 0) {
return PHP_STREAM_OPTION_RETURN_ERR;
}
- if (range->length == 0 && range->offset > 0 && range->offset < data->sb.st_size) {
- range->length = data->sb.st_size - range->offset;
- }
- if (range->length == 0 || range->length > data->sb.st_size) {
- range->length = data->sb.st_size;
- }
- if (range->offset >= data->sb.st_size) {
+ if (range->offset > data->sb.st_size) {
range->offset = data->sb.st_size;
- range->length = 0;
+ }
+ if (range->length == 0 ||
+ range->length > data->sb.st_size - range->offset) {
+ range->length = data->sb.st_size - range->offset;
}
switch (range->mode) {
case PHP_STREAM_MAP_MODE_READONLY: