From: Dan Carpenter <dan.carpenter@oracle.com>
To: "David S. Miller" <davem@davemloft.net>,
Jens Axboe <axboe@fb.com>, Sagi Grimberg <sagi@grimberg.me>
Cc: Wei Tang <tangwei@cmss.chinamobile.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
netdev@vger.kernel.org, linux-block@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH block-tree] net: off by one in inet6_pton()
Date: Thu, 13 Apr 2017 22:42:31 +0300 [thread overview]
Message-ID: <20170413194231.GD591@mwanda> (raw)
If "scope_len" is sizeof(scope_id) then we would put the NUL terminator
one space beyond the end of the buffer.
Fixes: b1a951fe469e ("net/utils: generic inet_pton_with_scope helper")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This one goes through Jens' tree not through net-dev.
diff --git a/net/core/utils.c b/net/core/utils.c
index da1089ea5389..93066bd0305a 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -339,7 +339,7 @@ static int inet6_pton(struct net *net, const char *src, u16 port_num,
src + srclen != scope_delim && *scope_delim == '%') {
struct net_device *dev;
char scope_id[16];
- size_t scope_len = min_t(size_t, sizeof(scope_id),
+ size_t scope_len = min_t(size_t, sizeof(scope_id) - 1,
src + srclen - scope_delim - 1);
memcpy(scope_id, scope_delim + 1, scope_len);
next reply other threads:[~2017-04-13 19:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-13 19:42 Dan Carpenter [this message]
2017-04-14 20:09 ` [PATCH block-tree] net: off by one in inet6_pton() Jens Axboe
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=20170413194231.GD591@mwanda \
--to=dan.carpenter@oracle.com \
--cc=adobriyan@gmail.com \
--cc=axboe@fb.com \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sagi@grimberg.me \
--cc=tangwei@cmss.chinamobile.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;
as well as URLs for NNTP newsgroup(s).