From: Dan Carpenter <dan.carpenter@oracle.com>
To: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Cc: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
Samuel Ortiz <sameo@linux.intel.com>,
"David S. Miller" <davem@davemloft.net>,
"John W. Linville" <linville@tuxdriver.com>,
Thierry Escande <thierry.escande@linux.intel.com>,
Szymon Janc <szymon.janc@tieto.com>,
linux-wireless@vger.kernel.org, linux-nfc@ml01.01.org,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] NFC: llcp: cleanup underflow check
Date: Fri, 1 Mar 2013 08:20:21 +0300 [thread overview]
Message-ID: <20130301052021.GB2669@longonot.mountain> (raw)
In-Reply-To: <2148581.S8tzak9aE2@uw000953>
Szymon Janc suggested I should move the lower bound check into the
caller and make it match the check for NFC_MAX_GT_LEN.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index 87a6417..e50dd2c 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -74,6 +74,7 @@ struct nfc_ops {
#define NFC_TARGET_IDX_ANY -1
#define NFC_MAX_GT_LEN 48
+#define NFC_MIN_GT_LEN 3
#define NFC_ATR_RES_GT_OFFSET 15
struct nfc_target {
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 6ceee8e..e2c3b6e 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -450,7 +450,7 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
{
pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
- if (gb_len > NFC_MAX_GT_LEN)
+ if (gb_len < NFC_MIN_GT_LEN || gb_len > NFC_MAX_GT_LEN)
return -EINVAL;
return nfc_llcp_set_remote_gb(dev, gb, gb_len);
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 7f8266d..7be27fb 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -547,8 +547,6 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len)
pr_err("No LLCP device\n");
return -ENODEV;
}
- if (gb_len < 3)
- return -EINVAL;
memset(local->remote_gb, 0, NFC_MAX_GT_LEN);
memcpy(local->remote_gb, gb, gb_len);
prev parent reply other threads:[~2013-03-01 5:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 8:16 [patch] NFC: llcp: integer underflow in nfc_llcp_set_remote_gb() Dan Carpenter
[not found] ` <20130131081645.GA14812-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2013-02-07 10:16 ` Szymon Janc
2013-03-01 5:20 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130301052021.GB2669@longonot.mountain \
--to=dan.carpenter@oracle.com \
--cc=aloisio.almeida@openbossa.org \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=lauro.venancio@openbossa.org \
--cc=linux-nfc@ml01.01.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=sameo@linux.intel.com \
--cc=szymon.janc@tieto.com \
--cc=thierry.escande@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox