diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-09-22 13:16:42 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-09-22 13:16:59 +0200 |
commit | f445e9cb93eff1856748aaa6d020b74a653d2d76 (patch) | |
tree | b0e5ec9ad45c45d9a0210d393283be7b2257738f /main/streams | |
parent | 19c844594e40d79cea016b54f9ab3a367440b4c9 (diff) | |
parent | 4000780b3d0bbba2d94f65602e602c3892d9775b (diff) | |
download | php-git-f445e9cb93eff1856748aaa6d020b74a653d2d76.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fix #79423: copy command is limited to size of file it can copy
Diffstat (limited to 'main/streams')
-rw-r--r-- | main/streams/plain_wrapper.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 298950cf9e..9ed920c022 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -771,6 +771,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam; HANDLE hfile = (HANDLE)_get_osfhandle(fd); DWORD prot, acc, loffs = 0, delta = 0; + LARGE_INTEGER file_size; switch (value) { case PHP_STREAM_MMAP_SUPPORTED: @@ -807,7 +808,22 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void return PHP_STREAM_OPTION_RETURN_ERR; } - size = GetFileSize(hfile, NULL); + if (!GetFileSizeEx(hfile, &file_size)) { + CloseHandle(data->file_mapping); + data->file_mapping = NULL; + return PHP_STREAM_OPTION_RETURN_ERR; + } +# if defined(_WIN64) + size = file_size.QuadPart; +# else + if (file_size.HighPart) { + CloseHandle(data->file_mapping); + data->file_mapping = NULL; + return PHP_STREAM_OPTION_RETURN_ERR; + } else { + size = file_size.LowPart; + } +# endif if (range->offset > size) { range->offset = size; } |