diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-16 15:34:31 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-16 15:34:31 +0100 |
commit | 0b1b21d62286b73b8c59a2ce12e75a6de0f84f13 (patch) | |
tree | a62fa3dd35ab373dbb4d107b0085c9a8b313f8c8 | |
parent | c3d36a5fe997f5bbd1ccdd61587653ff0bc5b20e (diff) | |
download | serenity-0b1b21d62286b73b8c59a2ce12e75a6de0f84f13.zip |
LibC: mmap() should not interpret high addresses as errors, oops!
-rw-r--r-- | LibC/mman.cpp | 6 |
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, ¶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) |