mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
the offset parameter of mmap() must be aligned to a page boundary (although linux doesnt strictly require it).
use 0 as offset as it will be small and increment the ptrs afterwards
This commit is contained in:
parent
68c140b288
commit
86df0f095d
1 changed files with 9 additions and 2 deletions
|
@ -214,11 +214,18 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
|
|||
#if HAVE_MMAP
|
||||
if (file_handle->handle.fp) {
|
||||
/* *buf[size] is zeroed automatically by the kernel */
|
||||
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), ftell(file_handle->handle.fp));
|
||||
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
|
||||
if (*buf != MAP_FAILED) {
|
||||
file_handle->handle.stream.mmap.len = size;
|
||||
long offset = ftell(file_handle->handle.fp);
|
||||
file_handle->handle.stream.mmap.map = *buf;
|
||||
|
||||
if (offset != -1) {
|
||||
*buf += offset;
|
||||
size -= offset;
|
||||
}
|
||||
file_handle->handle.stream.mmap.buf = *buf;
|
||||
file_handle->handle.stream.mmap.len = size;
|
||||
|
||||
goto return_mapped;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue