forecast: Restrict strncpy() call
authorNoel Kuntze <noel.kuntze@thermi.consulting>
Sat, 17 Apr 2021 03:02:01 +0000 (05:02 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 4 May 2021 12:48:53 +0000 (14:48 +0200)
Closes strongswan/strongswan#331.

src/libcharon/plugins/forecast/forecast_forwarder.c

index 42b57b1..4bb6ef3 100644 (file)
@@ -361,7 +361,8 @@ static int get_ifindex(private_kernel_listener_t *this, char *ifname)
 {
        struct ifreq ifr = {};
 
 {
        struct ifreq ifr = {};
 
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+       strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1);
+
        if (ioctl(this->raw, SIOCGIFINDEX, &ifr) == 0)
        {
                return ifr.ifr_ifindex;
        if (ioctl(this->raw, SIOCGIFINDEX, &ifr) == 0)
        {
                return ifr.ifr_ifindex;