mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix mmap copying
Instead of attempting to map large files into memory at once, we map chunks of at most `PHP_STREAM_MMAP_MAX` bytes, and repeat that until we hit the point where `php_stream_seek()` fails (see bug 54902), and copy the rest of the file by reading and writing small chunks. We also fix the mapping behavior for zero bytes on Windows, which did not error (as with `mmap()`), but would have mapped the remaining file.
This commit is contained in:
parent
d1feeed7f3
commit
19c844594e
4 changed files with 50 additions and 20 deletions
|
@ -826,6 +826,11 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
|
|||
delta = (DWORD)range->offset - loffs;
|
||||
}
|
||||
|
||||
/* MapViewOfFile()ing zero bytes would map to the end of the file; match *nix behavior instead */
|
||||
if (range->length + delta == 0) {
|
||||
return PHP_STREAM_OPTION_RETURN_ERR;
|
||||
}
|
||||
|
||||
data->last_mapped_addr = MapViewOfFile(data->file_mapping, acc, 0, loffs, range->length + delta);
|
||||
|
||||
if (data->last_mapped_addr) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue