From patchwork Mon Oct 19 08:06:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Otcheretianski, Andrei" X-Patchwork-Id: 1384050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=BsYGRsfe; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CF8Wj39vmz9ryj for ; Mon, 19 Oct 2020 19:08:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=HXVZH82v7c46TCOM0t96JKaC0mWuHdiLN8PpJOVTCvI=; b=BsYGRsfeasAHb5ALhlmW3pGEt9 pYgfie5WnEzcfnG76d6xdce0APLT9qfIv/lRA8xIl5OnEdwU4lWeLvMIPK1OEY/e6Lcw0wg3tXhGS Zp80LfTs/MGwsn1UHUlw6CLhP37Z8eG5bRNLP3ILIMP1PbtkeWHiCkimtz0jtB+vq9BnDEhr3Brf2 AfhOgf528KIEEL5xbtOBDg7YKBe6S87hl8YYdwaUhtoSGOSinuo+VIkbM0T8mKTwPEenz2t9a0KCE w56CTuyo9zu5/TFxXjMUhhRH+msznJrZeq87PvJlvSbw5Y2YQ/CKpB1ymCYNafSOzmm++eK8Rw9Zn CfBNXo8g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUQC6-0008Sm-AY; Mon, 19 Oct 2020 08:07:02 +0000 Received: from mga04.intel.com ([192.55.52.120]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUQC3-0008S4-26 for hostap@lists.infradead.org; Mon, 19 Oct 2020 08:07:00 +0000 IronPort-SDR: ef9bBIBM+wbNRtTPWQMKRxY4oGhDxgc0zGFFE0+cbM5zw52dvwHdnNtGH4RHqxUtkyplqWifq9 psoYaY/v2oOg== X-IronPort-AV: E=McAfee;i="6000,8403,9778"; a="164371704" X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="164371704" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2020 01:06:55 -0700 IronPort-SDR: D6jSUiqqGPKRsaypkJa+cxK54Mo37tnu8t/b/9pswb7+enTtDB3Zz9bejlmhpJcuCtQ9/Xn8Kd LQ0XsnpJ4P0Q== X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="523031305" Received: from ajahshan-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.251.167.145]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2020 01:06:54 -0700 From: Andrei Otcheretianski To: hostap@lists.infradead.org Subject: [PATCH] wpa_cli: Don't access uninitialized variables Date: Mon, 19 Oct 2020 11:06:28 +0300 Message-Id: <20201019080630.9115-1-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201019_040659_247792_637E9F05 X-CRM114-Status: GOOD ( 11.96 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [192.55.52.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrei Otcheretianski Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Don't print potentially uninitialized variables in wpa_ctrl_command_bss(). Some compilers and analyzers may warn about it. Signed-off-by: Andrei Otcheretianski --- wpa_supplicant/wpa_cli.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 51c9642e90..2ac282d979 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -3085,7 +3085,8 @@ static int wpa_cli_cmd_dpp_stop_chirp(struct wpa_ctrl *ctrl, int argc, static int wpa_ctrl_command_bss(struct wpa_ctrl *ctrl, const char *cmd) { - char buf[512], *pos, *bssid, *freq, *level, *flags, *ssid; + char buf[512], *pos, *bssid = NULL, *freq = NULL, *level = NULL, + *flags = NULL, *ssid = NULL; size_t len; int ret, id = -1; @@ -3126,7 +3127,9 @@ static int wpa_ctrl_command_bss(struct wpa_ctrl *ctrl, const char *cmd) *pos++ = '\0'; } if (id != -1) - printf("%s\t%s\t%s\t%s\t%s\n", bssid, freq, level, flags, ssid); + printf("%s\t%s\t%s\t%s\t%s\n", bssid ? bssid : "N/A", + freq ? freq : "N/A", level ? level : "N/A", + flags? flags : "N/A", ssid ? ssid : "N/A"); return id; }