diff options
| author | Antony Dovgal <tony2001@php.net> | 2006-11-29 11:12:59 +0000 |
|---|---|---|
| committer | Antony Dovgal <tony2001@php.net> | 2006-11-29 11:12:59 +0000 |
| commit | 60bb49460729d199a512bbe3bbb26ca143a6a0f2 (patch) | |
| tree | cdf08fd3100f67fbe8e12b5eb4844f33bbb84f0f /main | |
| parent | d5d1801df7d9dcd1a3aeb886da83189dbe20437d (diff) | |
| download | php-git-60bb49460729d199a512bbe3bbb26ca143a6a0f2.tar.gz | |
MFH: fix #39673 (file_get_contents causes bus error on certain offsets)
Diffstat (limited to 'main')
| -rw-r--r-- | main/streams/plain_wrapper.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index f268eaf07c..5bcbe6170b 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -627,9 +627,16 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void case PHP_STREAM_MMAP_MAP_RANGE: do_fstat(data, 1); + 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) { + range->offset = data->sb.st_size; + range->length = 0; + } switch (range->mode) { case PHP_STREAM_MAP_MODE_READONLY: prot = PROT_READ; |
