Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp368327lqo; Fri, 10 May 2024 02:19:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaNe3+s+hbgx0SX8XPVshpYra18DXrhWrdHNLvZOYujH6Jm4Z6GZ3saBHQgrJr01OjQu2rqkOD9SuHui5+cv0CeAW8r9roppAH8smBZw== X-Google-Smtp-Source: AGHT+IEZhRem3kYBe4LjT/5LCUNpduawRc4WWMFDx93AaXTjAtel91Y4AQNOmGCt2UHmL/Kg4F0a X-Received: by 2002:a50:c010:0:b0:572:7e9f:c124 with SMTP id 4fb4d7f45d1cf-5734d59040bmr1520601a12.9.1715332742027; Fri, 10 May 2024 02:19:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715332742; cv=pass; d=google.com; s=arc-20160816; b=SLkX8U9jvvL0HecFVTGK9vd6EqrS8vGLBXH14ZH/0j30G2IhvJTKG9Qw+Xz0kBQrxD qKvR5HX51n+XUNnlAfuWBpbd59MCR5MfApTVle0rLZLDVUho+E0/xGblgiZd60DVoDub uI2AgIE3VHogt/kSysE8iOO2LQUjEnkS2QJ1cH/1q5waHywfKlBm7W5t98Is7nwjjYHB Li51JuesVWOdjHZbnP8WC29kdoieO0shrGOAYIRT/vXbu7qu5Oq+srZQLIWPanSXYxy5 YL6aVI0AAjsmRCk5kihdX948K8S1TjqPpZxCFQLwViEJeyZtr5f5bhCs5mSxF2mSN8YL xFAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from; bh=Yk8nHozlPbebbYGLF91M67Jp743QNkftse5XNatH1ls=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=IOlo/K6Do9XnK54ZMvP5B/O7LhwGsIa8g0uV0mens0RoklkIdO/qApXKfepVmwUX+k SkCs1GvYcR6f2UVtq77QVOcYPJktyf95YJtAlrQUQqvbf+aIlA3TSe1R6DU/pVztupw6 q8UFP+C8+La759tiS0rwHBG0YJkmWp7B9lYfyz4hcwYYtuHNNiUQo6GXtHa4ng4tP7EV HsUFO9a/6veQU9CbaeEvuYPel/+yDuk1tagkArnplZ9mJRxvAcd0jIwZdlW5gImAZkTt v7JrH196QiCmbpkDnwfXLlftH+i7/Oo/gn5tghC41m7oRevmLeIqKHDYMEp+VJGclFCn glbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4456-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4456-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733bec15bdsi1778418a12.165.2024.05.10.02.19.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 02:19:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4456-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4456-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4456-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C1FDE1F21378 for ; Fri, 10 May 2024 09:19:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 584D1168B16; Fri, 10 May 2024 09:18:28 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 728C71607A3 for ; Fri, 10 May 2024 09:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715332708; cv=none; b=skyeSYu1Sj55QRtfJNNVkv8cKWHQlxg2C6yHLCLH+38GOsuQ0UScy9PFRdX8Is635emATRzi00kv2CdDzbTR3N03QzsdlYROiQ95P4spZPUyuhx/omrVSpXFxDlHeZTo0fU+IhO/KLUawZiA7m5yqCQscnvrJIcbHA3KE84OwgU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715332708; c=relaxed/simple; bh=ZfaaZ7dEeQ9VjznH7vB7wWyIi9NLs2xFK5M4PvwRoK4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G4YFcgykPtWevzkrsazTLvc5UoeHn+fNX4eQaInBdQYu7z37LuNrfucH1Qk0DVvivtvLyj3lYGjjvFgTR90sJr07fmIco7N/ZxdjcZptqwAkhrLxOW+kJ+HBNnl34W3lc8vL34+iCwvjNoGegeJhVwkJW6udTgBJrecPwvy5wBU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 904D41BF212 for ; Fri, 10 May 2024 09:18:17 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Subject: [BlueZ 11/14] isotest: Consider "0" fd to be valid Date: Fri, 10 May 2024 11:11:09 +0200 Message-ID: <20240510091814.3172988-12-hadess@hadess.net> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240510091814.3172988-1-hadess@hadess.net> References: <20240510091814.3172988-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: hadess@hadess.net Error: RESOURCE_LEAK (CWE-772): [#def79] [important] bluez-5.75/tools/isotest.c:923:4: open_fn: Returning handle opened by "open_file". bluez-5.75/tools/isotest.c:923:4: var_assign: Assigning: "fd" = handle returned from "open_file(altername)". bluez-5.75/tools/isotest.c:925:3: off_by_one: Testing whether handle "fd" is strictly greater than zero is suspicious. "fd" leaks when it is zero. bluez-5.75/tools/isotest.c:925:3: remediation: Did you intend to include equality with zero? bluez-5.75/tools/isotest.c:926:4: overwrite_var: Overwriting handle "fd" in "fd = open_file(filename)" leaks the handle. 924| 925| if (fd <= 0) 926|-> fd = open_file(filename); 927| } 928| --- tools/isotest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/isotest.c b/tools/isotest.c index 7e875fa58b15..810d15d2df2a 100644 --- a/tools/isotest.c +++ b/tools/isotest.c @@ -922,7 +922,7 @@ static void send_mode(char *filename, char *peer, int i, bool repeat) if (!err) fd = open_file(altername); - if (fd <= 0) + if (fd < 0) fd = open_file(filename); } -- 2.44.0