diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2018-05-03 17:21:15 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2018-05-03 17:21:15 +0200 |
commit | 4983ee551a743e55bb2f2ec12ceab0ddba13eb2d (patch) | |
tree | 39dc399369793e650521d637d7ade32743a599b8 /src/odhcpd.c | |
parent | 413652910234f44e11d6550abf6871621474b8cb (diff) |
odhcpd: fix strncpy bounds
Fix strncpy bounds as reported by Coverity in CID 1412278 and 1412293
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/odhcpd.c')
-rw-r--r-- | src/odhcpd.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/odhcpd.c b/src/odhcpd.c index 71b803d..8aa4571 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -143,10 +143,12 @@ int odhcpd_get_interface_config(const char *ifname, const char *what) int odhcpd_get_mac(const struct interface *iface, uint8_t mac[6]) { struct ifreq ifr; + memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, iface->ifname, sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name, iface->ifname, sizeof(ifr.ifr_name) - 1); if (ioctl(ioctl_sock, SIOCGIFHWADDR, &ifr) < 0) return -1; + memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); return 0; } |