From c00d70982fd3fbbb3fd429ddfa2b1d143f7ac9f0 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 12 Sep 2019 10:01:33 -0400 Subject: [PATCH] Evil: fix mmap() and define HAVE_MMAP Summary: add size of file mapping to fix invalid parameter Test Plan: compilation (edje succeeds) and elm_test Reviewers: zmike, cedric, raster Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9913 --- src/lib/evil/evil_dlfcn.h | 2 +- src/lib/evil/evil_mman.c | 12 +++++++++++- src/lib/evil/evil_mman.h | 4 ++++ src/lib/evil/evil_stdlib.h | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/lib/evil/evil_dlfcn.h b/src/lib/evil/evil_dlfcn.h index c6d5d1acf2..9e39be5967 100644 --- a/src/lib/evil/evil_dlfcn.h +++ b/src/lib/evil/evil_dlfcn.h @@ -144,7 +144,7 @@ struct Dl_info */ EAPI void *dlopen(const char* path, int mode); #ifndef HAVE_DLOPEN -#define HAVE_DLOPEN 1 +# define HAVE_DLOPEN 1 #endif /** * @brief Close a dynamic-link library. diff --git a/src/lib/evil/evil_mman.c b/src/lib/evil/evil_mman.c index dbcfc31901..42f8021e59 100644 --- a/src/lib/evil/evil_mman.c +++ b/src/lib/evil/evil_mman.c @@ -58,6 +58,8 @@ mmap(void *addr EVIL_UNUSED, DWORD acs = 0; HANDLE handle; void *data; + DWORD low; + DWORD high; /* get protection */ protect = _evil_mmap_protection_get(prot); @@ -89,7 +91,15 @@ mmap(void *addr EVIL_UNUSED, } } - fm = CreateFileMapping(handle, NULL, protect, 0, 0, NULL); +#ifdef _WIN64 + low = (DWORD)((len >> 32) & 0x00000000ffffffff); + low = (DWORD)(len & 0x00000000ffffffff); +#else + high = 0L; + low = len; +#endif + + fm = CreateFileMapping(handle, NULL, protect, high, low, NULL); if (!fm) { fprintf(stderr, "[Evil] [mmap] CreateFileMapping failed: %s\n", diff --git a/src/lib/evil/evil_mman.h b/src/lib/evil/evil_mman.h index 990d146058..747917d204 100644 --- a/src/lib/evil/evil_mman.h +++ b/src/lib/evil/evil_mman.h @@ -114,6 +114,10 @@ EAPI void *mmap(void *addr, int fd, off_t offset); +#ifndef HAVE_MMAP +# define HAVE_MMAP 1 +#endif + /** * Unmaps a mapped view of a file from the calling process's * address space. diff --git a/src/lib/evil/evil_stdlib.h b/src/lib/evil/evil_stdlib.h index a5645b7585..eae2fb8809 100644 --- a/src/lib/evil/evil_stdlib.h +++ b/src/lib/evil/evil_stdlib.h @@ -116,7 +116,7 @@ EAPI int mkstemps(char *__template, int suffixlen); */ EAPI char *realpath(const char *file_name, char *resolved_name); #ifndef HAVE_REALPATH -#define HAVE_REALPATH 1 +# define HAVE_REALPATH 1 #endif