Fix Coverity 156528: use strscpy to make sure strings are well terminated
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Mon, 6 Nov 2017 09:21:40 +0000 (10:21 +0100)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Mon, 6 Nov 2017 09:24:05 +0000 (10:24 +0100)
Fix Coverity 156529: use strscpy to make sure strings are well terminated

src-plugins/subsystems/os_linux/os_tunnel_linux.c

index d0966cb..c20151f 100644 (file)
@@ -293,7 +293,7 @@ _handle_ipv4_tunnel(struct os_tunnel *tunnel, bool add) {
     p.iph.tos = 1;
   }
 
-  strncpy(ifr.ifr_name, _tunnel_base_if[type], IF_NAMESIZE);
+  strscpy(ifr.ifr_name, _tunnel_base_if[type], IF_NAMESIZE);
 
   netaddr_to_binary(&p.iph.saddr, &tunnel->p.local, sizeof(p.iph.saddr));
   netaddr_to_binary(&p.iph.daddr, &tunnel->p.remote, sizeof(p.iph.daddr));
@@ -377,7 +377,7 @@ _handle_ipv6_tunnel(struct os_tunnel *tunnel, bool add) {
     p.hop_limit = tunnel->p.tunnel_ttl;
   }
 
-  strncpy(ifr.ifr_name, _tunnel_base_if[type], IF_NAMESIZE);
+  strscpy(ifr.ifr_name, _tunnel_base_if[type], IF_NAMESIZE);
 
   netaddr_to_binary(&p.laddr, &tunnel->p.local, sizeof(p.laddr));
   netaddr_to_binary(&p.raddr, &tunnel->p.remote, sizeof(p.raddr));