test: replace unsecure function with secure function

Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ie120ffa529798f0f087ddfcd34f5d9c5802b6766
This commit is contained in:
xuxinyu
2022-08-25 22:31:01 +08:00
parent 44ec199465
commit e0b4fcb23d
231 changed files with 884 additions and 400 deletions

View File

@@ -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;