Skip to content

Commit f445e9c

Browse files
committed
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
2 parents 19c8445 + 4000780 commit f445e9c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #80061 (Copying large files may have suboptimal performance).
77
(cmb)
8+
. Fixed bug #79423 (copy command is limited to size of file it can copy).
9+
(cmb)
810

911
- MySQLnd:
1012
. Fixed bug #80115 (mysqlnd.debug doesn't recognize absolute paths with

main/streams/plain_wrapper.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
771771
php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam;
772772
HANDLE hfile = (HANDLE)_get_osfhandle(fd);
773773
DWORD prot, acc, loffs = 0, delta = 0;
774+
LARGE_INTEGER file_size;
774775

775776
switch (value) {
776777
case PHP_STREAM_MMAP_SUPPORTED:
@@ -807,7 +808,22 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
807808
return PHP_STREAM_OPTION_RETURN_ERR;
808809
}
809810

810-
size = GetFileSize(hfile, NULL);
811+
if (!GetFileSizeEx(hfile, &file_size)) {
812+
CloseHandle(data->file_mapping);
813+
data->file_mapping = NULL;
814+
return PHP_STREAM_OPTION_RETURN_ERR;
815+
}
816+
# if defined(_WIN64)
817+
size = file_size.QuadPart;
818+
# else
819+
if (file_size.HighPart) {
820+
CloseHandle(data->file_mapping);
821+
data->file_mapping = NULL;
822+
return PHP_STREAM_OPTION_RETURN_ERR;
823+
} else {
824+
size = file_size.LowPart;
825+
}
826+
# endif
811827
if (range->offset > size) {
812828
range->offset = size;
813829
}

0 commit comments

Comments
 (0)