summaryrefslogtreecommitdiffstats
path: root/net/core/utils.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2017-04-13 22:42:31 +0300
committerJens Axboe <axboe@fb.com>2017-04-14 14:08:54 -0600
commita88086e09876f468356cfec5319ff62004e36a1b (patch)
tree3d4a3827e09b99da4c0a55b2a4d3d3b65aaebbd0 /net/core/utils.c
parent00e043936e9a1c274c29366c7ecd9e17c79418e6 (diff)
downloadlinux-a88086e09876f468356cfec5319ff62004e36a1b.tar.gz
linux-a88086e09876f468356cfec5319ff62004e36a1b.tar.bz2
linux-a88086e09876f468356cfec5319ff62004e36a1b.zip
net: off by one in inet6_pton()
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> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'net/core/utils.c')
-rw-r--r--net/core/utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/core/utils.c b/net/core/utils.c
index f96cf527bb8f..32c467cf52d6 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);