From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSzLf-0006xn-70 for qemu-devel@nongnu.org; Fri, 30 Jan 2009 14:48:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSzLe-0006x9-Lo for qemu-devel@nongnu.org; Fri, 30 Jan 2009 14:48:18 -0500 Received: from [199.232.76.173] (port=48783 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSzLe-0006wy-Fw for qemu-devel@nongnu.org; Fri, 30 Jan 2009 14:48:18 -0500 Received: from savannah.gnu.org ([199.232.41.3]:58103 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSzLe-0003wY-6e for qemu-devel@nongnu.org; Fri, 30 Jan 2009 14:48:18 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LSzLd-0003Vq-Pm for qemu-devel@nongnu.org; Fri, 30 Jan 2009 19:48:17 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LSzLd-0003Vl-GF for qemu-devel@nongnu.org; Fri, 30 Jan 2009 19:48:17 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Fri, 30 Jan 2009 19:48:17 +0000 Subject: [Qemu-devel] [6481] linuw-user fix: read() and acct() on NULL arguments Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6481 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6481 Author: aurel32 Date: 2009-01-30 19:48:17 +0000 (Fri, 30 Jan 2009) Log Message: ----------- 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 Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/linux-user/syscall.c Modified: trunk/linux-user/syscall.c =================================================================== --- trunk/linux-user/syscall.c 2009-01-30 19:48:07 UTC (rev 6480) +++ trunk/linux-user/syscall.c 2009-01-30 19:48:17 UTC (rev 6481) @@ -3437,10 +3437,14 @@ 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 @@ 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: