On Mar 21, 2019, at 3:19 PM, Bart Van Assche <bvanass...@acm.org> wrote:
This patch does not change any functionality but makes the code easier to read. Cc: Sagi Grimberg <s...@grimberg.me> Cc: Christoph Hellwig <h...@lst.de> Signed-off-by: Bart Van Assche <bvanass...@acm.org> --- net/core/utils.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/net/core/utils.c b/net/core/utils.c index 2a597ac7808e..5f11e89f173f 100644 --- a/net/core/utils.c +++ b/net/core/utils.c@@ -339,12 +339,8 @@ 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) - 1, - src + srclen - scope_delim - 1); - - memcpy(scope_id, scope_delim + 1, scope_len); - scope_id[scope_len] = '\0'; + strlcpy(scope_id, scope_delim + 1, sizeof(scope_id)); dev = dev_get_by_name(net, scope_id); if (dev) { addr6->sin6_scope_id = dev->ifindex; -- 2.21.0.155.ge902e9bcae20
This doesn't look right to me. The original code seemingly would stop the copy before getting to a possible '%' character. The new code only stops at eol. So this appears to change the functionality and I assume is broken in any case that uses the %. Take another look at what that min_t is really doing.
-- Mark Rustad, Networking Division, Intel Corporation
signature.asc
Description: Message signed with OpenPGP