[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] Force pread64/pwrite64 to return 0 for zero-length
From: |
Ilya Palachev |
Subject: |
[Qemu-devel] [PATCH] Force pread64/pwrite64 to return 0 for zero-length buffer |
Date: |
Wed, 17 Dec 2014 15:02:42 +0300 |
According to official standard POSIX.1-2001. pread64 and pwrite64
should return 0 for zero-length buffers as mentioned at
http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html
http://pubs.opengroup.org/onlinepubs/009695399/functions/write.html
Change-Id: Icd66ea29658329fbd5e6461d1def0c78c81d2671
Signed-off-by: Ilya Palachev <address@hidden>
---
linux-user/syscall.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a41dd43..a08f5ef 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8127,6 +8127,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_ulong
arg1,
arg4 = arg5;
arg5 = arg6;
}
+ if (!arg3) {
+ ret = 0;
+ break;
+ }
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
@@ -8137,6 +8141,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_ulong
arg1,
arg4 = arg5;
arg5 = arg6;
}
+ if (!arg3) {
+ ret = 0;
+ break;
+ }
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
--
2.1.3
- [Qemu-devel] [PATCH] Force pread64/pwrite64 to return 0 for zero-length buffer,
Ilya Palachev <=