dhcpv6: fix strncpy bounds
authorHans Dedecker <dedeckeh@gmail.com>
Sat, 21 Apr 2018 11:40:29 +0000 (13:40 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Sat, 21 Apr 2018 11:45:04 +0000 (13:45 +0200)
Fixes dhcpv6.c:138:2: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]                                                                                                        strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/dhcpv6.c

index 0b3585c6205eb88d40a3e36198c14c63f8694633..d70d533558abcd6525f766c35d9cef69d4c93a1a 100644 (file)
@@ -135,7 +135,7 @@ int init_dhcpv6(const char *ifname, unsigned int options, int sol_timeout)
        // Detect interface
        struct ifreq ifr;
        memset(&ifr, 0, sizeof(ifr));
-       strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+       strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
        if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0)
                goto failure;