From patchwork Wed Jan 6 03:05:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1422974 X-Patchwork-Delegate: daniel@makrotopia.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.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=SPlIk5Gs; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=tZK3kfdo; 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 4D9tgT2mV2z9sVx for ; Thu, 7 Jan 2021 02:33:41 +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=G2kitYRZURSzk9xSnZnhSHUmgaqavxT8QRkL1Vlgc8A=; b=SPlIk5Gs7+gkCcUoPfASpOzE3s 87U239aAYCrIYG5WKB/oY4wMez+E3wUcolJTGauGF7sE4QK9a6R2ZgyrUv2VdWLMoXbriyasRQaRf +7xbWdVgxTo4YocI6OZFAs7O0ddm4TbNRYjxigrRNlzkL5xov6B5XStaTS/ggZm0OgTO1V6a5x2Dv DqOgDwsmoPZyCx0zOJ9gkbJB1jcOHBpM3U9W4DRR3gwdAl3fSBoC1KovGoTOiXrW1oj3C5Ccf9AWj h6OGwBUM8ksViZprst45BKdutotKlmOVPDUIwZZM0E/nnFGPoO28UIMQaNgEIebc/f6niv/PAStky BCX2SNFQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxAmr-00012d-Td; Wed, 06 Jan 2021 15:31:49 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxAmo-00011x-JF for openwrt-devel@lists.openwrt.org; Wed, 06 Jan 2021 15:31:47 +0000 Received: by mail-ed1-x52e.google.com with SMTP id g24so4718220edw.9 for ; Wed, 06 Jan 2021 07:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dheT9w3neIQWFp8wK5v+aJwhFBWBwvVAYB9nXFHHK/8=; b=tZK3kfdoxB/f03ibkzMADokoZGCgncOEsnn9gseraWHmRCI5AQcteug2y/qvVPnlH/ qxoJODmW+WjJbJs0BQaQRk1KBTPmFL/f7UHztbA7yzHN2VDzC8QzPceUmrMYTHNcPdXX EcDuxYxyKPVyKvJDIvj/CN/mSoHk9lVlaXc0GzhsA88YqQ5gQ8ro5Cbnx5YHhORsB0Vh x7x88YdubN6giyVM5buNde7/cmz98+IhlVerf2pp6e+cBXp6MCoPNdZX7kh70zHUQJcI n7EA1oKKuozcfp+xM87xrqBckaRZZzx4inYyGkz++B0QTJWnmJLW0eYETgTnEBbgtZxM /P8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dheT9w3neIQWFp8wK5v+aJwhFBWBwvVAYB9nXFHHK/8=; b=jlmSZJ2MOM5uZbuIAjkWzR70Le3pXLBCoOb1MQkKqvP+BibYxRqj/+Cwf3xu10t+S6 eFI9sNbcN9DPzyGnXnFsJVTHoiPO8RefYWjabruwPcHoMlL3dfvjuoIM94h5awwGusfh AR7PtKeRII8srgKKxCAcstmCUPMa4wgFdkSiT5+HmjV2V3MRPG8ing5ZyEob8+BSX7gU 0sS0oMtR/8CcqnQ+5BtkAjq1RaswUeUpeg8okrKQd8P5a0vVcfC/2td8cCfSj0owCu33 0RENM8oPis8SnOlI2kwBytqw/S+EF2escHu+0zvQjKWo84pfOQiCIK/T6iik7YWmZ4G8 wdAA== X-Gm-Message-State: AOAM533VMRVhqh9/9tiG7ZrXPdnXSqIUzUOu69YXKGhebvnpxAaAcX0c IswQDlsJmKBkdE2+tdTWn1MSxudL8aA= X-Google-Smtp-Source: ABdhPJwSiu+PrdXuDBziI9a8Vbt6tlbG84um/wtUD8tTXkbT6xvesibyhWi13cGzr1aML981YN0BGA== X-Received: by 2002:aa7:d608:: with SMTP id c8mr4205397edr.260.1609947105020; Wed, 06 Jan 2021 07:31:45 -0800 (PST) Received: from ansuel-xps20.localdomain (host-87-3-254-254.retail.telecomitalia.it. [87.3.254.254]) by smtp.googlemail.com with ESMTPSA id dh19sm1582436edb.78.2021.01.06.07.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 07:31:44 -0800 (PST) From: Ansuel Smith To: openwrt-devel@lists.openwrt.org Subject: [IWINFO PATCH] iwinfo: improve center channel handling Date: Wed, 6 Jan 2021 04:05:37 +0100 Message-Id: <20210106030537.18930-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210106_103146_658552_B0C242F7 X-CRM114-Status: GOOD ( 13.83 ) X-Spam-Score: 0.6 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:52e listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.8 DATE_IN_PAST_12_24 Date: is 12 to 24 hours before Received: date -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ansuel Smith Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org - Improve iwinfo center channel struct position - Prevent read beyond buffer on malformed data Signed-off-by: Ansuel Smith --- include/iwinfo.h | 4 ++-- iwinfo_nl80211.c | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/iwinfo.h b/include/iwinfo.h index 5799c02..40ef3a7 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -255,6 +255,8 @@ struct iwinfo_ops { int (*probe)(const char *ifname); int (*mode)(const char *, int *); int (*channel)(const char *, int *); + int (*center_chan1)(const char *, int *); + int (*center_chan2)(const char *, int *); int (*frequency)(const char *, int *); int (*frequency_offset)(const char *, int *); int (*txpower)(const char *, int *); @@ -283,8 +285,6 @@ struct iwinfo_ops { int (*survey)(const char *, char *, int *); int (*lookup_phy)(const char *, char *); void (*close)(void); - int (*center_chan1)(const char *, int *); - int (*center_chan2)(const char *, int *); }; const char * iwinfo_type(const char *ifname); diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 5ca5c03..ba5bddb 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -2380,14 +2380,18 @@ static void nl80211_get_scanlist_ie(struct nlattr **bss, IWINFO_CIPHER_TKIP, IWINFO_KMGMT_PSK); break; case 61: /* HT oeration */ - e->ht_chan_info.primary_chan = ie[2]; - e->ht_chan_info.secondary_chan_off = ie[3] & 0x3; - e->ht_chan_info.chan_width = (ie[4] & 0x4)>>2; + if (ie[1] >= 3) { + e->ht_chan_info.primary_chan = ie[2]; + e->ht_chan_info.secondary_chan_off = ie[3] & 0x3; + e->ht_chan_info.chan_width = (ie[4] & 0x4)>>2; + } break; case 192: /* VHT operation */ - e->vht_chan_info.chan_width = ie[2]; - e->vht_chan_info.center_chan_1 = ie[3]; - e->vht_chan_info.center_chan_2 = ie[4]; + if (ie[1] >= 3) { + e->vht_chan_info.chan_width = ie[2]; + e->vht_chan_info.center_chan_1 = ie[3]; + e->vht_chan_info.center_chan_2 = ie[4]; + } break; } @@ -3317,6 +3321,8 @@ const struct iwinfo_ops nl80211_ops = { .name = "nl80211", .probe = nl80211_probe, .channel = nl80211_get_channel, + .center_chan1 = nl80211_get_center_chan1, + .center_chan2 = nl80211_get_center_chan2, .frequency = nl80211_get_frequency, .frequency_offset = nl80211_get_frequency_offset, .txpower = nl80211_get_txpower, @@ -3345,7 +3351,5 @@ const struct iwinfo_ops nl80211_ops = { .countrylist = nl80211_get_countrylist, .survey = nl80211_get_survey, .lookup_phy = nl80211_lookup_phyname, - .close = nl80211_close, - .center_chan1 = nl80211_get_center_chan1, - .center_chan2 = nl80211_get_center_chan2 + .close = nl80211_close };