ip_tunnel: Fix name string concatenate in __ip_tunnel_create() 50/220150/3
authorSultan Alsawaf <sultanxda@gmail.com>
Wed, 6 Jun 2018 22:56:54 +0000 (15:56 -0700)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 16 Dec 2019 01:32:07 +0000 (10:32 +0900)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
[sw0312.kim: cherry-pick mainline commit 000ade80164 for gcc 9 build]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Iea412bf5398b91fcdc471952a289d406ea26d677

net/ipv4/ip_tunnel.c

index 84aa69c..c703867 100644 (file)
@@ -292,8 +292,8 @@ static struct net_device *__ip_tunnel_create(struct net *net,
                        err = -E2BIG;
                        goto failed;
                }
-               strlcpy(name, ops->kind, IFNAMSIZ);
-               strncat(name, "%d", 2);
+               strcpy(name, ops->kind);
+               strcat(name, "%d");
        }
 
        ASSERT_RTNL();