[][mii_mgr: fix coverity errors]
[Description]
Fix BUFFER_SIZE error reported by coverity.
[Release-log]
N/A
Change-Id: I06d34e2fbc90e1e59171bba8cc77916305826213
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5395187
diff --git a/feed/mii_mgr/src/mii_mgr.c b/feed/mii_mgr/src/mii_mgr.c
index b4e6696..2ca5071 100644
--- a/feed/mii_mgr/src/mii_mgr.c
+++ b/feed/mii_mgr/src/mii_mgr.c
@@ -65,7 +65,8 @@
if (sd < 0)
return sd;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
+ ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
if (is_priv) {
fill_mtk_mii_ioctl(&mtk_mii, phy_id, reg_num, val);
@@ -117,7 +118,8 @@
is_priv = 0;
break;
case 'i':
- strncpy(ifname,optarg, 5);
+ strncpy(ifname, optarg, 5);
+ ifname[IFNAMSIZ - 1] = '\0';
break;
case 'p':
port = strtoul(optarg, NULL, 16);