* [PATCH block-tree] net: off by one in inet6_pton()
@ 2017-04-13 19:42 Dan Carpenter
2017-04-14 20:09 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-04-13 19:42 UTC (permalink / raw)
To: David S. Miller, Jens Axboe, Sagi Grimberg
Cc: Wei Tang, Alexey Dobriyan, netdev, linux-block, kernel-janitors
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);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH block-tree] net: off by one in inet6_pton()
2017-04-13 19:42 [PATCH block-tree] net: off by one in inet6_pton() Dan Carpenter
@ 2017-04-14 20:09 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2017-04-14 20:09 UTC (permalink / raw)
To: Dan Carpenter, David S. Miller, Sagi Grimberg
Cc: Wei Tang, Alexey Dobriyan, netdev, linux-block, kernel-janitors
On 04/13/2017 01:42 PM, Dan Carpenter wrote:
> If "scope_len" is sizeof(scope_id) then we would put the NUL terminator
> one space beyond the end of the buffer.
Added, thanks Dan.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-14 20:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-13 19:42 [PATCH block-tree] net: off by one in inet6_pton() Dan Carpenter
2017-04-14 20:09 ` Jens Axboe
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).