mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
Fixed bug #50982 (incorrect assumption of PAGE_SIZE size)
This commit is contained in:
parent
facdc8a7aa
commit
653e374b6b
1 changed files with 21 additions and 5 deletions
|
@ -27,10 +27,24 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#if HAVE_SYS_MMAN_H
|
#if HAVE_MMAP
|
||||||
|
# if HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
# if defined(_SC_PAGESIZE)
|
||||||
|
# define REAL_PAGE_SIZE sysconf(_SC_PAGESIZE);
|
||||||
|
# elif defined(_SC_PAGE_SIZE)
|
||||||
|
# define REAL_PAGE_SIZE sysconf(_SC_PAGE_SIZE);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# if HAVE_SYS_MMAN_H
|
||||||
# include <sys/mman.h>
|
# include <sys/mman.h>
|
||||||
# ifndef PAGE_SIZE
|
# endif
|
||||||
# define PAGE_SIZE 4096
|
# ifndef REAL_PAGE_SIZE
|
||||||
|
# ifdef PAGE_SIZE
|
||||||
|
# define REAL_PAGE_SIZE PAGE_SIZE
|
||||||
|
# else
|
||||||
|
# define REAL_PAGE_SIZE 4096
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -215,9 +229,11 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
|
||||||
|
|
||||||
if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) {
|
if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) {
|
||||||
#if HAVE_MMAP
|
#if HAVE_MMAP
|
||||||
|
size_t page_size = REAL_PAGE_SIZE;
|
||||||
|
|
||||||
if (file_handle->handle.fp &&
|
if (file_handle->handle.fp &&
|
||||||
size != 0 &&
|
size != 0 &&
|
||||||
((size - 1) % PAGE_SIZE) <= PAGE_SIZE - ZEND_MMAP_AHEAD) {
|
((size - 1) % page_size) <= page_size - ZEND_MMAP_AHEAD) {
|
||||||
/* *buf[size] is zeroed automatically by the kernel */
|
/* *buf[size] is zeroed automatically by the kernel */
|
||||||
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
|
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
|
||||||
if (*buf != MAP_FAILED) {
|
if (*buf != MAP_FAILED) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue