From c9576dd4f47b108611b6489215fc935d67aba69d Mon Sep 17 00:00:00 2001 From: GetAway Date: Tue, 18 Jun 2019 22:59:07 +0200 Subject: [PATCH] fix some strncpy warnings when build with gcc8 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/54ccbfc5d17b13995b6d096159bf54cc1cec471a Author: GetAway Date: 2019-06-18 (Tue, 18 Jun 2019) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libiw/iwlib.c | 12 ++++++------ lib/libiw/iwlib.h | 4 ++-- lib/libiw/iwscan.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/libiw/iwlib.c b/lib/libiw/iwlib.c index 0afa8c1e4..cede7fda7 100644 --- a/lib/libiw/iwlib.c +++ b/lib/libiw/iwlib.c @@ -675,7 +675,7 @@ iw_get_basic_config(int skfd, return(-1); else { - strncpy(info->name, wrq.u.name, IFNAMSIZ); + strncpy(info->name, wrq.u.name, IFNAMSIZ-1); info->name[IFNAMSIZ] = '\0'; } @@ -755,7 +755,7 @@ iw_set_basic_config(int skfd, */ if(info->has_mode) { - strncpy(wrq.ifr_name, ifname, IFNAMSIZ); + strncpy(wrq.ifr_name, ifname, IFNAMSIZ-1); wrq.u.mode = info->mode; if(iw_get_ext(skfd, ifname, SIOCSIWMODE, &wrq) < 0) @@ -1272,7 +1272,7 @@ iw_get_stats(int skfd, wrq.u.data.pointer = (caddr_t) stats; wrq.u.data.length = sizeof(struct iw_statistics); wrq.u.data.flags = 1; /* Clear updated flag */ - strncpy(wrq.ifr_name, ifname, IFNAMSIZ); + strncpy(wrq.ifr_name, ifname, IFNAMSIZ-1); if(iw_get_ext(skfd, ifname, SIOCGIWSTATS, &wrq) < 0) return(-1); @@ -1936,7 +1936,7 @@ iw_check_mac_addr_type(int skfd, struct ifreq ifr; /* Get the type of hardware address */ - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1); if((ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) || ((ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) && (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211))) @@ -1970,7 +1970,7 @@ iw_check_if_addr_type(int skfd, struct ifreq ifr; /* Get the type of interface address */ - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1); if((ioctl(skfd, SIOCGIFADDR, &ifr) < 0) || (ifr.ifr_addr.sa_family != AF_INET)) { @@ -2258,7 +2258,7 @@ iw_in_addr(int skfd, arp_query.arp_flags = 0; /* The following restrict the search to the interface only */ /* For old kernels which complain, just comment it... */ - strncpy(arp_query.arp_dev, ifname, IFNAMSIZ); + strncpy(arp_query.arp_dev, ifname, IFNAMSIZ-1); if((ioctl(skfd, SIOCGARP, &arp_query) < 0) || !(arp_query.arp_flags & ATF_COM)) { diff --git a/lib/libiw/iwlib.h b/lib/libiw/iwlib.h index c0fbe9461..555a6756d 100644 --- a/lib/libiw/iwlib.h +++ b/lib/libiw/iwlib.h @@ -507,7 +507,7 @@ iw_set_ext(int skfd, /* Socket to the kernel */ struct iwreq * pwrq) /* Fixed part of the request */ { /* Set device name */ - strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); + strncpy(pwrq->ifr_name, ifname, IFNAMSIZ-1); /* Do the request */ return(ioctl(skfd, request, pwrq)); } @@ -523,7 +523,7 @@ iw_get_ext(int skfd, /* Socket to the kernel */ struct iwreq * pwrq) /* Fixed part of the request */ { /* Set device name */ - strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); + strncpy(pwrq->ifr_name, ifname, IFNAMSIZ-1); /* Do the request */ return(ioctl(skfd, request, pwrq)); } diff --git a/lib/libiw/iwscan.cpp b/lib/libiw/iwscan.cpp index 65ee3ff53..42824826b 100644 --- a/lib/libiw/iwscan.cpp +++ b/lib/libiw/iwscan.cpp @@ -46,7 +46,7 @@ static void device_up(std::string dev) memset(&ifr, 0, sizeof ifr); - strncpy(ifr.ifr_name, dev.c_str(), IFNAMSIZ); + strncpy(ifr.ifr_name, dev.c_str(), IFNAMSIZ-1); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) perror("SIOCGIFFLAGS");