I've slightly re-organised the check to more closely match the sequence that the kernel uses in do_mmap().
Signed-off-by: Alex Bennée <email address hidden> Cc: umarcor <email address hidden> --- linux-user/mmap.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d0c50e4888..3ef69fa2d0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -391,14 +391,22 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, } #endif
- if (offset & ~TARGET_PAGE_MASK) { + if (!len) { errno = EINVAL; goto fail; }
len = TARGET_PAGE_ALIGN(len); - if (len == 0) - goto the_end; + if (!len) { + errno = EINVAL; + goto fail; + } + + if (offset & ~TARGET_PAGE_MASK) { + errno = EINVAL; + goto fail; + } + real_start = start & qemu_host_page_mask; host_offset = offset & qemu_host_page_mask;
-- 2.17.1
I've slightly re-organised the check to more closely match the
sequence that the kernel uses in do_mmap().
Signed-off-by: Alex Bennée <email address hidden>
Cc: umarcor <email address hidden>
---
linux-user/mmap.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c .3ef69fa2d0 100644 mmap(abi_ ulong start, abi_ulong len, int prot,
index d0c50e4888.
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -391,14 +391,22 @@ abi_long target_
}
#endif
- if (offset & ~TARGET_PAGE_MASK) {
+ if (!len) {
errno = EINVAL;
goto fail;
}
len = TARGET_ PAGE_ALIGN( len); page_mask; page_mask;
- if (len == 0)
- goto the_end;
+ if (!len) {
+ errno = EINVAL;
+ goto fail;
+ }
+
+ if (offset & ~TARGET_PAGE_MASK) {
+ errno = EINVAL;
+ goto fail;
+ }
+
real_start = start & qemu_host_
host_offset = offset & qemu_host_
--
2.17.1