From patchwork Sun Feb 26 14:43:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 94525 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp501537qgi; Sun, 26 Feb 2017 06:46:33 -0800 (PST) X-Received: by 10.200.49.129 with SMTP id h1mr11356655qte.277.1488120393268; Sun, 26 Feb 2017 06:46:33 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j37si7355958qtc.49.2017.02.26.06.46.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 26 Feb 2017 06:46:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:47171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci05n-0006pF-07 for patch@linaro.org; Sun, 26 Feb 2017 09:46:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci03P-0005f1-9B for qemu-devel@nongnu.org; Sun, 26 Feb 2017 09:44:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ci03M-00026A-7E for qemu-devel@nongnu.org; Sun, 26 Feb 2017 09:44:03 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:51269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci03M-00025k-0l for qemu-devel@nongnu.org; Sun, 26 Feb 2017 09:44:00 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 0DA2FB3F8; Sun, 26 Feb 2017 15:43:58 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DHQu6NH3IqF9; Sun, 26 Feb 2017 15:43:56 +0100 (CET) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 2CA27B47C; Sun, 26 Feb 2017 15:43:56 +0100 (CET) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.88) (envelope-from ) id 1ci03G-0000f6-Rp; Sun, 26 Feb 2017 15:43:54 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sun, 26 Feb 2017 15:43:51 +0100 Message-Id: <20170226144353.2502-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170226144353.2502-1-samuel.thibault@ens-lyon.org> References: <20170226144353.2502-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 141.255.128.1 Subject: [Qemu-devel] [PULL 1/3] slirp: Check qemu_socket() return value in udp_listen() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jan.kiszka@siemens.com, stefanha@redhat.com, Samuel Thibault Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Check the return value from qemu_socket() rather than trying to pass it to bind() as an fd argument even if it's negative. This wouldn't have caused any negative consequences, because it won't be a valid fd number and the bind call will fail; but Coverity complains (CID 1005723). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Samuel Thibault --- slirp/udp.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.11.0 diff --git a/slirp/udp.c b/slirp/udp.c index 93d7224792..227d779022 100644 --- a/slirp/udp.c +++ b/slirp/udp.c @@ -335,6 +335,10 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, return NULL; } so->s = qemu_socket(AF_INET,SOCK_DGRAM,0); + if (so->s < 0) { + sofree(so); + return NULL; + } so->so_expire = curtime + SO_EXPIRE; insque(so, &slirp->udb);