Skip to contentSkip to conversation

linux-user: fix special case pwrite64 with count = 0

PATCH New Carlo Marcelo Arenas Belón 1 participant 1 message Oct 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: fix special case pwrite64 with count = 0

building on the work from Zhuowei Zhang for making write return 0 instead of -1 when called with: write(fd, NULL, 0)

---
 linux-user/syscall.c | 4 ++++
 1 file changed, 4 insertions(+)
linux-user/syscall.c +4 -0
index 9b6364a266..89e883f187 100644
@@ -10509,6 +10509,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             arg4 = arg5;
             arg5 = arg6;
         }
+        if (arg2 == 0 && arg3 == 0) {
+            ret = get_errno(pwrite64(arg1, NULL, arg3, target_offset64(arg4, arg5)));
+            break;
+        }
         if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
             goto efault;
         ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
Signature · 1 line
2.14.2