Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1357104lqb; Thu, 30 May 2024 08:01:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+ziU7Z/JG3MoAs/FheAhI4RhmdC6Nfv7VPRZhSK3jNwtQJCck1LgextfOnriJsmbbFRdmlPwUS6z+R+2v+2vvwr3/UoM8EyTCu57LEw== X-Google-Smtp-Source: AGHT+IGT7ldRKno+1jC4c44GZfH5o2UnFjy4je6mX/OyVNjxX5uhwlbtgrFIW4M0lWx7ia6HFPCt X-Received: by 2002:ac2:4835:0:b0:52b:84a1:32d9 with SMTP id 2adb3069b0e04-52b84a133c0mr1519e87.38.1717081278967; Thu, 30 May 2024 08:01:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717081278; cv=pass; d=google.com; s=arc-20160816; b=ASuOHe5sYC+1rokCXTanVPjWJ7WHHPOgGEdpm2GZ5hgOLT/QGmHmreDkwRB7mXthZR lfGy7MiEflaH0shHHGXL79jFtymFT/iTn4D8ZhMs9xtjsVtM/vfitycwBRusbY5KW9Nr DIz/2tX8ntdn1H4hlJI7MYznQkyV5ciYQQ8sy70fGMPkaqwmoLAc7YFNlIK7/SUbEG+H 36/YNF+8dipuZp4KKpaZVXXJdMgqS013q0FPf4KV/bsELweqXEo/bdSPeU8NSft0AoM/ tnVJFLWFWUOWTEGGPBlurmAjNCUXwWNtnW//8+A0ygt/Y/42XTHQgK6fZXxXZOdrQZKD BZSw== 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:cc:to:from; bh=7YrG6zGh+BTTJEKwv8WBygu4RWyp9Z5rBeTbs/zBC0A=; fh=uo5u2TQK/HQlhydMwGLjBAnuDwaLxndJ/cgWTjIagS8=; b=n71QIE/fYjGXQYEq974nHI9zMmvV0RdeFVeidGkcXOa7GfTosm/qWpZGCKYIwq/76t ksyfvyxEmvCoGOqfRE/7LxFzQJKpx2cj3hvu/p3t/16d069QDjtIRKUlHpf5oNhL4N/7 6BBNMW1kwrgmHy3co9ofGtZhhtyM9B3Yoz+dSP8eGu1KYrg9NZGAXQp8EN7O+TnXZoUR nnr93oQZ+y8lGCA/mHbHmF2pe/ZHPDdUPJN2OZca2MMIJyzx5AlMMaQK9zStRBtu+kRU vRy2InRg+lS/da3CWWPxMcrEsMcHvXU/bCGFaSM2Dnn6WZlPF9axipHhssXVizhU+XJQ lmZg==; 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-5039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5039-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 a640c23a62f3a-a626cdcfc60si758302666b.959.2024.05.30.08.01.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 08:01:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-5039-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-5039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5039-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 AA4EC1F22D76 for ; Thu, 30 May 2024 15:01:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78C1A145A01; Thu, 30 May 2024 15:01:03 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 2DC2D1E532 for ; Thu, 30 May 2024 15:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081263; cv=none; b=bUqqR994JOQdPARwsrjiaxfA3MZHkyOaFFHxt26nU8Wg1veV6xxdmKMGHBjby3RE/ajV57wGbal9ShIi3Gtp/JVp9AcEZFC/mVXgsWIWkQA2UwettWG+Eg/xyvLR0Ok9aklXie0uheqQPfVTLiW3OaRSzLF2k2yRA7Q1IDjanoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081263; c=relaxed/simple; bh=vs7XiLagZa5ntsanP3R0MRDHQ8gAeVOhTp8wK47UJK8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lvy8MegikkYUBC1oXnvsuxer4dzyXQNYNp3PSbr6r0FJjWvlnxnawTf9zKndeEIhFs/AZ2tEU0oh1AVCov36DUv7CaFoFT9dZoyhmyz2rKUqQYh/h51uX0z5cJl297ieuqh6MmQJA7gxjDuji0Rs3qq6wddaKhfR2djaxu50iFo= 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.200 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 50B362000E; Thu, 30 May 2024 15:00:58 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ 2/9] mgmt-tester: Fix buffer overrun Date: Thu, 30 May 2024 16:57:56 +0200 Message-ID: <20240530150057.444585-3-hadess@hadess.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240530150057.444585-1-hadess@hadess.net> References: <20240530150057.444585-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: OVERRUN (CWE-119): [#def56] [important] bluez-5.76/tools/mgmt-tester.c:12667:2: identity_transfer: Passing "512UL" as argument 3 to function "vhci_read_devcd", which returns that argument. bluez-5.76/tools/mgmt-tester.c:12667:2: assignment: Assigning: "read" = "vhci_read_devcd(vhci, buf, 512UL)". The value of "read" is now 512. bluez-5.76/tools/mgmt-tester.c:12674:2: overrun-local: Overrunning array "buf" of 513 bytes at byte offset 513 using index "read + 1" (which evaluates to 513). 12672| } 12673| /* Make sure buf is nul-terminated */ 12674|-> buf[read + 1] = '\0'; 12675| 12676| /* Verify if all devcoredump header fields are present */ Fixes: 49d06560692f ("mgmt-tester: Fix non-nul-terminated string") --- tools/mgmt-tester.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index 8076ec105ebb..1d5c82ae0745 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -12671,7 +12671,7 @@ static void verify_devcd(void *user_data) return; } /* Make sure buf is nul-terminated */ - buf[read + 1] = '\0'; + buf[read] = '\0'; /* Verify if all devcoredump header fields are present */ line = strtok_r(buf, delim, &saveptr); -- 2.45.1