From patchwork Mon Feb 27 14:07:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SiWon Kang X-Patchwork-Id: 732843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vX3Tj2rrJz9s7Z for ; Tue, 28 Feb 2017 01:08:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o1TlSsD2"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ehDjkc66"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=zFPx8OZKM94c+pzYJG3gmQhBBK2hXwfCCZjQCaUw9mA=; b=o1T lSsD2ZNWDXksjM3QaHj+4bwJ9+BPAKH0FArLRFPdsjuHj8r5z3QC9KaxJSJ+7NcCfJZmu8qAknTs2 UilmcSLNGIVx5kgUuXsbP6N90rjUkbM+2lnhQhdzhUc+acTH0pCqoUjYIcNpRzw6IQplols8hQ7V7 ztB6phttEeIJGeMy3CzpSkwJ1yG31Kg9mq4B11mG9qHpPqsJv1Tmflj1/kQZ/IMvyCbhkQR93FBFd CxFxHaDeH2o9dWARzcRX255I35UcV1As/a/G2HHStIUI4Z2zppgksi1NuQCGkryKFm/Wugc7kfk4R PxSOW4s6l1BAWmBBmzxdfeEB1Ycg+dg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ciLy7-0003YL-Ua; Mon, 27 Feb 2017 14:08:03 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ciLxh-0003VZ-I5 for hostap@lists.infradead.org; Mon, 27 Feb 2017 14:07:40 +0000 Received: by mail-lf0-x244.google.com with SMTP id z127so6286749lfa.2 for ; Mon, 27 Feb 2017 06:07:16 -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; bh=0B959rUkREd7RFlrWGp419CqV2jYS9eWX5GLC1AM8T8=; b=ehDjkc66IDKFFasOuzbiO+UbPcfVI0y6IL+Tk3Z8FvPF4k9qgdmKDVnyMGXWK5mSZS jgI4cI4AO6QSm98sSqcmfsn62Eq3eysuZq8rgZ8T0nSWDULM2wh0CbqL9KSmrYuDJ2RT Whe5V32hSflPMOUFX1T3iSsYrc8yc1EI1fGrdXFPH1GelAPBqSKVps2TM6dGaFnZw0hh gagsNW2sopQtDUdu9rokYw9qojH0B0Fv8lCz0G/F6Hvu4ra2z6YSFEi3czhCwzcElhQ7 HAZNLRIo+imK73vrBvOAZsToFlDy6rGVBLm2JNT+PaafgBhYKGh54x4VtY8SRiDN/UCG Fi9A== 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; bh=0B959rUkREd7RFlrWGp419CqV2jYS9eWX5GLC1AM8T8=; b=AFUMBxoaHVY3rXpgIFXLWrfzLGQ+se1Z8tzeQc0bliZRDxX8SXqSm25nYKgpj0DiER 7ixuE5gJVr0Df00JIjZW9YJFHLYH3UqT964jGapU0GmjVp7/gXu3QuUl0c/xRLyaOlbR 0Lfv2cBgTdIDv6GmrGIJbDk84jxtcG/xXKj/p7T1gIS1mKdyAvgrFYoU/Z0Izw54rUdb +ga4jory2uuIVEwOT9yl5PfWOTQvB/4pnpgi0pkW8GXgwGz9B8wUp/+OKM3QrnOjJ36+ tEJXrLcaWyxUO+EcvdqBzj9HYjqHJYY0mrJvU3aK0G/evm9BnJtIvyYWRz7lAT0vqT+q qUjA== X-Gm-Message-State: AMke39m/m/oDd/N3MZV1wmDoCztXlHWu1j5g8n3yVEYKgVtudoCft9GQ7QnuYNYUcQBGYw== X-Received: by 10.25.37.65 with SMTP id l62mr4786453lfl.137.1488204435044; Mon, 27 Feb 2017 06:07:15 -0800 (PST) Received: from localhost.localdomain (samsung-230.novipark.dk. [77.243.61.230]) by smtp.gmail.com with ESMTPSA id g26sm992728lfh.46.2017.02.27.06.07.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Feb 2017 06:07:14 -0800 (PST) From: Siwon Kang To: hostap@lists.infradead.org Subject: [PATCH] Fix a channel-to-frequency transformation in ieee80211_chan_to_freq() Date: Mon, 27 Feb 2017 23:07:08 +0900 Message-Id: <1488204428-23395-1-git-send-email-kkangshawn@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170227_060737_862770_B3023A76 X-CRM114-Status: GOOD ( 10.32 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c07:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (kkangshawn[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Siwon Kang MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The function ieee80211_chan_to_freq() is supposed to return -1 if the specified channel is unknown. However, current if-conditional statements do not catch a few wrong combination. For example, {"US", 81, 13} for country code, operating class, channel, respectively should return -1 because op_class 81 is not in the list and channel 13 is not allowed but currently returns 2472 as if it is global. This patch removes 'if (freq > 0)' to prevent from stepping over when an input op_class is out of the list of a country then finally going to ieee80211_chan_to_freq_global(). Instead, it returns result of sub-function directly which is correct. Signed-off-by: Siwon Kang --- src/common/ieee802_11_common.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index a8d68e5..5ba5071 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -1133,31 +1133,17 @@ static int ieee80211_chan_to_freq_global(u8 op_class, u8 chan) */ int ieee80211_chan_to_freq(const char *country, u8 op_class, u8 chan) { - int freq; + if (country_match(us_op_class_cc, country)) + return ieee80211_chan_to_freq_us(op_class, chan); - if (country_match(us_op_class_cc, country)) { - freq = ieee80211_chan_to_freq_us(op_class, chan); - if (freq > 0) - return freq; - } - - if (country_match(eu_op_class_cc, country)) { - freq = ieee80211_chan_to_freq_eu(op_class, chan); - if (freq > 0) - return freq; - } + if (country_match(eu_op_class_cc, country)) + return ieee80211_chan_to_freq_eu(op_class, chan); - if (country_match(jp_op_class_cc, country)) { - freq = ieee80211_chan_to_freq_jp(op_class, chan); - if (freq > 0) - return freq; - } + if (country_match(jp_op_class_cc, country)) + return ieee80211_chan_to_freq_jp(op_class, chan); - if (country_match(cn_op_class_cc, country)) { - freq = ieee80211_chan_to_freq_cn(op_class, chan); - if (freq > 0) - return freq; - } + if (country_match(cn_op_class_cc, country)) + return ieee80211_chan_to_freq_cn(op_class, chan); return ieee80211_chan_to_freq_global(op_class, chan); }