From patchwork Mon Dec 31 19:53:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 208894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8A06E2C0090 for ; Tue, 1 Jan 2013 06:53:57 +1100 (EST) Received: from localhost ([::1]:49344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TplQg-0004wq-HW for incoming@patchwork.ozlabs.org; Mon, 31 Dec 2012 14:53:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TplQZ-0004wa-Sd for qemu-devel@nongnu.org; Mon, 31 Dec 2012 14:53:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TplQY-0007Hz-SJ for qemu-devel@nongnu.org; Mon, 31 Dec 2012 14:53:39 -0500 Received: from smtp6-g21.free.fr ([2a01:e0c:1:1599::15]:41996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TplQY-0007Hl-8a for qemu-devel@nongnu.org; Mon, 31 Dec 2012 14:53:38 -0500 Received: from localhost.localdomain (unknown [78.238.229.36]) by smtp6-g21.free.fr (Postfix) with ESMTP id 8FB7D82273; Mon, 31 Dec 2012 20:53:33 +0100 (CET) From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 31 Dec 2012 20:53:30 +0100 Message-Id: <1356983610-14793-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::15 Cc: Riku Voipio , Laurent Vivier Subject: [Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Laurent Vivier Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e99adab..1530c8f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1491,6 +1491,25 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, break; case TARGET_SOL_SOCKET: switch (optname) { + case TARGET_SO_RCVTIMEO: { + struct timeval tv; + + optname = SO_RCVTIMEO; + +set_timeout: + if (optlen != sizeof(struct target_timeval)) + return -TARGET_EINVAL; + + if (copy_from_user_timeval(&tv, optval_addr)) + return -TARGET_EFAULT; + + ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname, + &tv, sizeof(tv))); + return ret; + } + case TARGET_SO_SNDTIMEO: + optname = SO_SNDTIMEO; + goto set_timeout; /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; @@ -1542,13 +1561,6 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, case TARGET_SO_RCVLOWAT: optname = SO_RCVLOWAT; break; - case TARGET_SO_RCVTIMEO: - optname = SO_RCVTIMEO; - break; - case TARGET_SO_SNDTIMEO: - optname = SO_SNDTIMEO; - break; - break; default: goto unimplemented; }