lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 21 Mar 2019 15:19:46 -0700
From:   Bart Van Assche <bvanassche@....org>
To:     David Miller <davem@...emloft.net>
Cc:     netdev@...r.kernel.org, Bart Van Assche <bvanassche@....org>,
        Sagi Grimberg <sagi@...mberg.me>,
        Christoph Hellwig <hch@....de>
Subject: [PATCH 7/7] net/utils: Use strlcpy() instead of open-coding it

This patch does not change any functionality but makes the code easier
to read.

Cc: Sagi Grimberg <sagi@...mberg.me>
Cc: Christoph Hellwig <hch@....de>
Signed-off-by: Bart Van Assche <bvanassche@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ