change strcpy to strlcpy

Change-Id: I8b9429a3c225a82842fce136bdb14b8b135066d3
Signed-off-by: lilei19 <lilei19@xiaomi.com>
This commit is contained in:
lilei19
2023-02-09 19:01:32 +08:00
committed by Xiang Xiao
parent e86745b9a2
commit 41f60bd669
33 changed files with 238 additions and 180 deletions

View File

@@ -237,7 +237,7 @@ FAR struct ipt_replace *netlib_ipt_prepare(FAR const char *table)
return NULL;
}
strcpy(info.name, table);
strlcpy(info.name, table, sizeof(info.name));
len = sizeof(info);
if (getsockopt(sockfd, IPPROTO_IP, IPT_SO_GET_INFO, &info, &len) < 0)
@@ -253,7 +253,7 @@ FAR struct ipt_replace *netlib_ipt_prepare(FAR const char *table)
goto errout;
}
strcpy(entries->name, table);
strlcpy(entries->name, table, sizeof(entries->name));
entries->size = info.size;
if (getsockopt(sockfd, IPPROTO_IP, IPT_SO_GET_ENTRIES, entries, &len) < 0)
{
@@ -268,7 +268,7 @@ FAR struct ipt_replace *netlib_ipt_prepare(FAR const char *table)
goto errout_with_entries;
}
strcpy(repl->name, table);
strlcpy(repl->name, table, sizeof(repl->name));
repl->valid_hooks = info.valid_hooks;
repl->num_entries = info.num_entries;
@@ -562,7 +562,8 @@ FAR struct ipt_entry *netlib_ipt_masquerade_entry(FAR const char *ifname)
IPT_FILL_ENTRY(entry, XT_MASQUERADE_TARGET);
strcpy(entry->entry.ip.outiface, ifname);
strlcpy(entry->entry.ip.outiface, ifname,
sizeof(entry->entry.ip.outiface));
memset(entry->entry.ip.outiface_mask, 0xff, len + 1);
return &entry->entry;