test: replace unsecure function with secure function
Signed-off-by: xuxinyu <xuxinyu6@huawei.com> Change-Id: Ie120ffa529798f0f087ddfcd34f5d9c5802b6766
This commit is contained in:
@@ -77,7 +77,8 @@ static unsigned IfName2Index(int fd, const char *name)
|
||||
struct ifreq ifr;
|
||||
int ret;
|
||||
|
||||
(void)strncpy_s(ifr.ifr_name, sizeof(ifr.ifr_name) - 1, name, sizeof(ifr.ifr_name) - 1);
|
||||
ret = strncpy_s(ifr.ifr_name, sizeof(ifr.ifr_name) - 1, name, sizeof(ifr.ifr_name) - 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
|
||||
ret = ioctl(fd, SIOCGIFINDEX, &ifr);
|
||||
return ret < 0 ? 0 : ifr.ifr_ifindex;
|
||||
|
||||
Reference in New Issue
Block a user