From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaqtY-0007FS-HR for qemu-devel@nongnu.org; Wed, 14 Dec 2011 10:37:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaqtX-00036F-7A for qemu-devel@nongnu.org; Wed, 14 Dec 2011 10:37:24 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:52765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaqtW-00035v-RM for qemu-devel@nongnu.org; Wed, 14 Dec 2011 10:37:23 -0500 From: Peter Maydell Date: Wed, 14 Dec 2011 15:37:17 +0000 Message-Id: <1323877039-19891-2-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1323877039-19891-1-git-send-email-peter.maydell@linaro.org> References: <1323877039-19891-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , patches@linaro.org It's valid to pass a NULL value pointer to setxattr, so don't fail this case EFAULT. Signed-off-by: Peter Maydell --- linux-user/syscall.c | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f227097..ca4503d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7655,11 +7655,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; case TARGET_NR_setxattr: { - void *p, *n, *v; + void *p, *n, *v = 0; + if (arg3) { + v = lock_user(VERIFY_READ, arg3, arg4, 1); + if (!v) { + ret = -TARGET_EFAULT; + break; + } + } p = lock_user_string(arg1); n = lock_user_string(arg2); - v = lock_user(VERIFY_READ, arg3, arg4, 1); - if (p && n && v) { + if (p && n) { ret = get_errno(setxattr(p, n, v, arg4, arg5)); } else { ret = -TARGET_EFAULT; @@ -7671,11 +7677,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; case TARGET_NR_getxattr: { - void *p, *n, *v; + void *p, *n, *v = 0; + if (arg3) { + v = lock_user(VERIFY_WRITE, arg3, arg4, 0); + if (!v) { + ret = -TARGET_EFAULT; + break; + } + } p = lock_user_string(arg1); n = lock_user_string(arg2); - v = lock_user(VERIFY_WRITE, arg3, arg4, 0); - if (p && n && v) { + if (p && n) { ret = get_errno(getxattr(p, n, v, arg4)); } else { ret = -TARGET_EFAULT; -- 1.7.5.4