From 0b1b21d62286b73b8c59a2ce12e75a6de0f84f13 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Feb 2019 15:34:31 +0100 Subject: [PATCH] LibC: mmap() should not interpret high addresses as errors, oops! --- LibC/mman.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LibC/mman.cpp b/LibC/mman.cpp index a2393f3b02..8cba6f83af 100644 --- a/LibC/mman.cpp +++ b/LibC/mman.cpp @@ -9,7 +9,11 @@ void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset) { Syscall::SC_mmap_params params { (dword)addr, size, prot, flags, fd, offset }; int rc = syscall(SC_mmap, ¶ms); - __RETURN_WITH_ERRNO(rc, (void*)rc, (void*)-1); + if (rc < 0 && -rc < EMAXERRNO) { + errno = -rc; + return (void*)-1; + } + return (void*)rc; } int munmap(void* addr, size_t size)