Commit e89f07d38427dc9e3aab17298d1bc0d339ed3004
1 parent
06c949e6
Make target_mmap always return -1 on failure.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1741 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
13 additions
and
7 deletions
linux-user/elfload.c
| ... | ... | @@ -890,7 +890,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, |
| 890 | 890 | interpreter_fd, |
| 891 | 891 | eppnt->p_offset - TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr)); |
| 892 | 892 | |
| 893 | - if (error > -1024UL) { | |
| 893 | + if (error == -1) { | |
| 894 | 894 | /* Real error */ |
| 895 | 895 | close(interpreter_fd); |
| 896 | 896 | free(elf_phdata); | ... | ... |
linux-user/mmap.c
| ... | ... | @@ -183,8 +183,10 @@ long target_mmap(unsigned long start, unsigned long len, int prot, |
| 183 | 183 | } |
| 184 | 184 | #endif |
| 185 | 185 | |
| 186 | - if (offset & ~TARGET_PAGE_MASK) | |
| 187 | - return -EINVAL; | |
| 186 | + if (offset & ~TARGET_PAGE_MASK) { | |
| 187 | + errno = EINVAL; | |
| 188 | + return -1; | |
| 189 | + } | |
| 188 | 190 | |
| 189 | 191 | len = TARGET_PAGE_ALIGN(len); |
| 190 | 192 | if (len == 0) |
| ... | ... | @@ -232,8 +234,10 @@ long target_mmap(unsigned long start, unsigned long len, int prot, |
| 232 | 234 | } |
| 233 | 235 | } |
| 234 | 236 | |
| 235 | - if (start & ~TARGET_PAGE_MASK) | |
| 236 | - return -EINVAL; | |
| 237 | + if (start & ~TARGET_PAGE_MASK) { | |
| 238 | + errno = EINVAL; | |
| 239 | + return -1; | |
| 240 | + } | |
| 237 | 241 | end = start + len; |
| 238 | 242 | host_end = HOST_PAGE_ALIGN(end); |
| 239 | 243 | |
| ... | ... | @@ -244,8 +248,10 @@ long target_mmap(unsigned long start, unsigned long len, int prot, |
| 244 | 248 | /* msync() won't work here, so we return an error if write is |
| 245 | 249 | possible while it is a shared mapping */ |
| 246 | 250 | if ((flags & MAP_TYPE) == MAP_SHARED && |
| 247 | - (prot & PROT_WRITE)) | |
| 248 | - return -EINVAL; | |
| 251 | + (prot & PROT_WRITE)) { | |
| 252 | + errno = EINVAL; | |
| 253 | + return -1; | |
| 254 | + } | |
| 249 | 255 | retaddr = target_mmap(start, len, prot | PROT_WRITE, |
| 250 | 256 | MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, |
| 251 | 257 | -1, 0); | ... | ... |