summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-16 15:34:31 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-16 15:34:31 +0100
commit0b1b21d62286b73b8c59a2ce12e75a6de0f84f13 (patch)
treea62fa3dd35ab373dbb4d107b0085c9a8b313f8c8
parentc3d36a5fe997f5bbd1ccdd61587653ff0bc5b20e (diff)
downloadserenity-0b1b21d62286b73b8c59a2ce12e75a6de0f84f13.zip
LibC: mmap() should not interpret high addresses as errors, oops!
-rw-r--r--LibC/mman.cpp6
1 files changed, 5 insertions, 1 deletions
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, &params);
- __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)