Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp368184lqo; Fri, 10 May 2024 02:18:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVu9uFZ6HS/rP5yV6UcBzM+dl/DjrU2YHxxAmkVJFb0qx8RSnq5nCbVikwkLFSu80N5OFPUCM1elWjKNyn5mE82T/YYJqmt+hhMUw1J+Q== X-Google-Smtp-Source: AGHT+IHLPgBca8iCkrm9i1WRxDbwhUJ98X0dF3TIqpmKrtggNB+das0LgyCUEjDGi7zOul7cpBSE X-Received: by 2002:a05:620a:2947:b0:790:72ab:251d with SMTP id af79cd13be357-792bbdd9cc2mr842790985a.12.1715332722564; Fri, 10 May 2024 02:18:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715332722; cv=pass; d=google.com; s=arc-20160816; b=kfIIjxPFg0gkP7hbY3UDreQUHROQ6LiwOngnUfgNwxmdejbizfQL3g+6VeGs35yWoT 8u8alRV8yWCyYDZNuKabZTTdsQB1CWcnlgotpPMZge2qeMrhin53OIy7C0Tddg10AhBO UbK6PitKY6JhdRxIzHCgnooUQiAaWw4CIUwbRC7aNhclQcALf7ZchfugxsogBzJECEit /hhW4qERNRldFd2J1jcGLWyMy4EV9KrHY9L2wjTX2aEs7yAMomzCb/T0hmov+zqozuD1 vqbQe6ugZ79uBr6Zl3HTMRITtgCvHBZUUGHnd29/Q4BnQ8swTGQMRehJNk/vy7fEN8sL UCpQ== 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=8NfJv7Vyv0mhJeavNysYLl0y0YM9kyN2qjYu1yxiXgk=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=xzVT5nfrrI8ofLnOn2887mEPhueETtCoWAaxPuiy66q9uKOBWrvjL5dgNz4HT/DMm7 JIuMLnSquG9p8h5gV5C1Jm+CIFxmZqBFQSBkiEuBNNp26p1eCRTkNEEeouZ7i2HmG37z KONWwzCI/+errVJVrTTBnqlsALPPyIWB7zkZW5kmxoaQgad3RjmT2M1TpViL0e0R2/Xy 7jEn8YzkBLyOQf1mb4xwOHNOXpDOssB8GhfxHX5RkiV5vq1Zwp/+0M3jSGzyYcQHiHwM nZCrcETWLX6i+4Vuz+qA8haG1FnymJlst9VoVMuQDVl+nBr1rIplvLXaz5tCT3WUMM8x at7A==; 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-4447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4447-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf335d2dsi329061685a.430.2024.05.10.02.18.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 02:18:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4447-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 721FF1C22084 for ; Fri, 10 May 2024 09:18:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C588165FB5; Fri, 10 May 2024 09:18:25 +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 378B01635C9 for ; Fri, 10 May 2024 09:18:22 +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=1715332704; cv=none; b=keojEzcl6i0EO5/ySrVjhtD2qdHXUjYIrOm7h8G9Pvs+tUI6l2LWrEykd9T4dlg3b4gfqBMC8WJUG1AvEPHuP81oEbm/33+O6OWIFsg4RU3tpSyhfdJUA256q417NaIpEEKpSZH7hFAQKi4095y+sr7D5rzV8lNHtNLAo7N4atk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715332704; c=relaxed/simple; bh=P+yjKjRjvdbaSXIaURzo3y+tgDv6GopWUV9BqCIn29k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q1vQhVV7rPUHJWIym6KfljFdw/zVrT8OCYIpcAA7IzWCqvJMsYaX9hKY6XLWUAqNDl2wVPjBqsEcrh32bQlXxUoUSGKrTho8HUGH/A3CUqUTSc38dUKJ18SlZlt+0+KArH9JI9DvfHLSP942NQa/qA+nYaZeaj4HOsrBfjCaOv4= 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 5995E1BF209 for ; Fri, 10 May 2024 09:18:16 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Subject: [BlueZ 05/14] client/main: Fix array access Date: Fri, 10 May 2024 11:11:03 +0200 Message-ID: <20240510091814.3172988-6-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: CPPCHECK_WARNING (CWE-788): [#def36] bluez-5.75/client/main.c:833: error[ctuArrayIndex]: Array index out of bounds; 'argv' buffer size is 0 and it is accessed at offset 1. 831| const char **opt; 832| 833|-> if (!strcmp(argv[1], "help")) { 834| for (opt = arg_table; opt && *opt; opt++) 835| bt_shell_printf("%s\n", *opt); --- client/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/main.c b/client/main.c index 51d08a67aa1a..f703cc91b24a 100644 --- a/client/main.c +++ b/client/main.c @@ -830,6 +830,11 @@ static gboolean parse_argument(int argc, char *argv[], const char **arg_table, { const char **opt; + if (argc < 2) { + bt_shell_printf("Missing argument to %s\n", argv[0]); + return FALSE; + } + if (!strcmp(argv[1], "help")) { for (opt = arg_table; opt && *opt; opt++) bt_shell_printf("%s\n", *opt); -- 2.44.0