All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ip_tunnel: Fix name string concatenate in __ip_tunnel_create()
@ 2018-06-06 22:56 Sultan Alsawaf
  2018-06-07 20:32 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Sultan Alsawaf @ 2018-06-06 22:56 UTC (permalink / raw)
  To: sultanxda; +Cc: netdev, davem, kuznet, yoshfuji

By passing a limit of 2 bytes to strncat, strncat is limited to writing
fewer bytes than what it's supposed to append to the name here.

Since the bounds are checked on the line above this, just remove the string
bounds checks entirely since they're unneeded.

Signed-off-by: Sultan Alsawaf <sultanxda@gmail.com>
---
 net/ipv4/ip_tunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 38d906baf1df..c4f5602308ed 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -261,8 +261,8 @@ static struct net_device *__ip_tunnel_create(struct net *net,
 	} else {
 		if (strlen(ops->kind) > (IFNAMSIZ - 3))
 			goto failed;
-		strlcpy(name, ops->kind, IFNAMSIZ);
-		strncat(name, "%d", 2);
+		strcpy(name, ops->kind);
+		strcat(name, "%d");
 	}
 
 	ASSERT_RTNL();
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ip_tunnel: Fix name string concatenate in __ip_tunnel_create()
  2018-06-06 22:56 [PATCH] ip_tunnel: Fix name string concatenate in __ip_tunnel_create() Sultan Alsawaf
@ 2018-06-07 20:32 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-06-07 20:32 UTC (permalink / raw)
  To: sultanxda; +Cc: netdev, kuznet, yoshfuji

From: Sultan Alsawaf <sultanxda@gmail.com>
Date: Wed,  6 Jun 2018 15:56:54 -0700

> By passing a limit of 2 bytes to strncat, strncat is limited to writing
> fewer bytes than what it's supposed to append to the name here.
> 
> Since the bounds are checked on the line above this, just remove the string
> bounds checks entirely since they're unneeded.
> 
> Signed-off-by: Sultan Alsawaf <sultanxda@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-07 20:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-06 22:56 [PATCH] ip_tunnel: Fix name string concatenate in __ip_tunnel_create() Sultan Alsawaf
2018-06-07 20:32 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.