From nobody Tue Feb 10 03:39:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150012198620923.718834677372; Sat, 15 Jul 2017 05:33:06 -0700 (PDT) Received: from localhost ([::1]:42004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWMFs-0006Fj-T3 for importer@patchew.org; Sat, 15 Jul 2017 08:33:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWMDv-00059J-13 for qemu-devel@nongnu.org; Sat, 15 Jul 2017 08:31:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWMDu-000643-1A for qemu-devel@nongnu.org; Sat, 15 Jul 2017 08:31:03 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:52260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWMDt-00063p-QO for qemu-devel@nongnu.org; Sat, 15 Jul 2017 08:31:01 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 5525BC7B9; Sat, 15 Jul 2017 14:31:01 +0200 (CEST) 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 YiejvIz-WyCN; Sat, 15 Jul 2017 14:31:00 +0200 (CEST) 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 32177D6E9; Sat, 15 Jul 2017 14:30:59 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.89) (envelope-from ) id 1dWMDq-0002EM-FR; Sat, 15 Jul 2017 14:30:58 +0200 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Sat, 15 Jul 2017 14:30:55 +0200 Message-Id: <20170715123057.8529-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170715123057.8529-1-samuel.thibault@ens-lyon.org> References: <20170715123057.8529-1-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PULL 2/4] slirp: fork_exec(): Don't close() a negative number in fork_exec() 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: Peter Maydell , Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell In a fork_exec() error path we try to closesocket(s) when s might be a negative number because the thing that failed was the qemu_socket() call. Add a guard so we don't do this. (Spotted by Coverity: CID 1005727 issue 1 of 2.) Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Samuel Thibault --- slirp/misc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slirp/misc.c b/slirp/misc.c index 88e9d94197..260187b6b6 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -112,7 +112,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty) bind(s, (struct sockaddr *)&addr, addrlen) < 0 || listen(s, 1) < 0) { error_report("Error: inet socket: %s", strerror(errno)); - closesocket(s); + if (s >=3D 0) { + closesocket(s); + } =20 return 0; } --=20 2.13.2