aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-30 19:48:17 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-30 19:48:17 +0000
commit38d840e6790c29f5928d8e62711b9f721b58b3dd (patch)
tree430957f624caae721d7a44cf827ce805516be9dd /linux-user
parenta516e72d60803cac3b81b3330db55983b080d8da (diff)
linuw-user fix: read() and acct() on NULL arguments
Returning efault in these cases is not correct. Originally proposed by Thayne Harbaugh in 2007: http://www.mail-archive.com/qemu-devel@nongnu.org/msg14658.html Signed-off-by: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6481 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/syscall.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8296e5e43f..3e21bb311c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3437,10 +3437,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = 0; /* avoid warning */
break;
case TARGET_NR_read:
- if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
- goto efault;
- ret = get_errno(read(arg1, p, arg3));
- unlock_user(p, arg2, ret);
+ if (arg3 == 0)
+ ret = 0;
+ else {
+ if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
+ goto efault;
+ ret = get_errno(read(arg1, p, arg3));
+ unlock_user(p, arg2, ret);
+ }
break;
case TARGET_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
@@ -3941,10 +3945,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
goto unimplemented;
#endif
case TARGET_NR_acct:
- if (!(p = lock_user_string(arg1)))
- goto efault;
- ret = get_errno(acct(path(p)));
- unlock_user(p, arg1, 0);
+ if (arg1 == 0) {
+ ret = get_errno(acct(NULL));
+ } else {
+ if (!(p = lock_user_string(arg1)))
+ goto efault;
+ ret = get_errno(acct(path(p)));
+ unlock_user(p, arg1, 0);
+ }
break;
#ifdef TARGET_NR_umount2 /* not on alpha */
case TARGET_NR_umount2: