Skip to content

Commit

Permalink
[nozzle] move away from strncpy to make coverity and gcc10 happy
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Jan 21, 2020
1 parent 5bd3c7d commit ae1caca
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions libnozzle/libnozzle.c
Expand Up @@ -109,7 +109,7 @@ static void destroy_iface(nozzle_t nozzle)

#ifdef KNET_BSD
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
memmove(ifname, nozzle->name, IFNAMSIZ);

ioctl(lib_cfg.ioctlfd, SIOCIFDESTROY, &ifr);
#endif
Expand All @@ -127,7 +127,7 @@ static int get_iface_mtu(const nozzle_t nozzle)
struct ifreq ifr;

memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
memmove(ifname, nozzle->name, IFNAMSIZ);

err = ioctl(lib_cfg.ioctlfd, SIOCGIFMTU, &ifr);
if (err) {
Expand Down Expand Up @@ -155,7 +155,7 @@ static int get_iface_mac(const nozzle_t nozzle, char **ether_addr)

memset(&mac, 0, MACADDR_CHAR_MAX);
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
memmove(ifname, nozzle->name, IFNAMSIZ);

#ifdef KNET_LINUX
err = ioctl(lib_cfg.ioctlfd, SIOCGIFHWADDR, &ifr);
Expand Down Expand Up @@ -523,7 +523,7 @@ nozzle_t nozzle_open(char *devname, size_t devname_size, const char *updownpath)
savederrno = EBUSY;
goto out_error;
}
strncpy(devname, curnozzle, IFNAMSIZ);
memmove(devname, curnozzle, IFNAMSIZ);
memmove(nozzle->name, curnozzle, IFNAMSIZ - 1);
#endif

Expand All @@ -547,7 +547,7 @@ nozzle_t nozzle_open(char *devname, size_t devname_size, const char *updownpath)
goto out_error;
}

strncpy(devname, ifname, IFNAMSIZ);
memmove(devname, ifname, IFNAMSIZ);
memmove(nozzle->name, ifname, IFNAMSIZ - 1);
#endif

Expand Down Expand Up @@ -732,7 +732,7 @@ int nozzle_set_up(nozzle_t nozzle)
}

memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
memmove(ifname, nozzle->name, IFNAMSIZ);

err = ioctl(lib_cfg.ioctlfd, SIOCGIFFLAGS, &ifr);
if (err) {
Expand Down Expand Up @@ -777,7 +777,7 @@ int nozzle_set_down(nozzle_t nozzle)
}

memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
memmove(ifname, nozzle->name, IFNAMSIZ);

err = ioctl(lib_cfg.ioctlfd, SIOCGIFFLAGS, &ifr);
if (err) {
Expand Down Expand Up @@ -878,7 +878,7 @@ int nozzle_set_mac(nozzle_t nozzle, const char *ether_addr)
}

memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
memmove(ifname, nozzle->name, IFNAMSIZ);
#ifdef KNET_LINUX
err = ioctl(lib_cfg.ioctlfd, SIOCGIFHWADDR, &ifr);
if (err) {
Expand Down Expand Up @@ -1025,7 +1025,7 @@ int nozzle_set_mtu(nozzle_t nozzle, const int mtu)
}

memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
memmove(ifname, nozzle->name, IFNAMSIZ);
ifr.ifr_mtu = mtu;

err = ioctl(lib_cfg.ioctlfd, SIOCSIFMTU, &ifr);
Expand Down

0 comments on commit ae1caca

Please sign in to comment.