mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-20 08:10:33 +01:00
core: replace strcpy() with g_strlcpy()
When copying device names into ioctl structs, we know that the device names are of valid length, so we were using strcpy(). But you can't prove that they're short enough just looking at the local code, so some code analysis tools warn about a potential buffer overflow.. So use g_strlcpy() instead.
This commit is contained in:
parent
f378457f25
commit
d6a07c60e9
2 changed files with 6 additions and 6 deletions
|
|
@ -121,7 +121,7 @@ rtnl_link_vlan_get_id (struct rtnl_link *l)
|
|||
if ((if_name = rtnl_link_get_name (l)) == NULL)
|
||||
return -1;
|
||||
|
||||
strcpy (if_request.device1, if_name);
|
||||
g_strlcpy (if_request.device1, if_name, sizeof (if_request.device1));
|
||||
|
||||
if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
nm_log_err (LOGD_DEVICE, "couldn't open control socket.");
|
||||
|
|
@ -158,7 +158,7 @@ rtnl_link_vlan_set_flags (struct rtnl_link *l, unsigned int flags)
|
|||
}
|
||||
|
||||
memset (&if_request, 0, sizeof (struct vlan_ioctl_args));
|
||||
strcpy (if_request.device1, if_name);
|
||||
g_strlcpy (if_request.device1, if_name, sizeof (if_request.device1));
|
||||
if_request.cmd = SET_VLAN_FLAG_CMD;
|
||||
if_request.u.flag = flags;
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ rtnl_link_vlan_set_ingress_map (struct rtnl_link *l, int from, uint32_t to)
|
|||
}
|
||||
|
||||
memset (&if_request, 0, sizeof (struct vlan_ioctl_args));
|
||||
strcpy (if_request.device1, if_name);
|
||||
g_strlcpy (if_request.device1, if_name, sizeof (if_request.device1));
|
||||
if_request.cmd = SET_VLAN_INGRESS_PRIORITY_CMD;
|
||||
if_request.u.skb_priority = from;
|
||||
if_request.vlan_qos = to;
|
||||
|
|
@ -223,7 +223,7 @@ rtnl_link_vlan_set_egress_map (struct rtnl_link *l, int from, uint32_t to)
|
|||
}
|
||||
|
||||
memset (&if_request, 0, sizeof (struct vlan_ioctl_args));
|
||||
strcpy (if_request.device1, if_name);
|
||||
g_strlcpy (if_request.device1, if_name, sizeof (if_request.device1));
|
||||
if_request.cmd = SET_VLAN_EGRESS_PRIORITY_CMD;
|
||||
if_request.u.skb_priority = from;
|
||||
if_request.vlan_qos = to;
|
||||
|
|
|
|||
|
|
@ -1743,7 +1743,7 @@ nm_system_iface_compat_add_vlan_device (const char *master, int vid)
|
|||
}
|
||||
|
||||
memset (&if_request, 0, sizeof (struct vlan_ioctl_args));
|
||||
strcpy (if_request.device1, master);
|
||||
g_strlcpy (if_request.device1, master, sizeof (if_request.device1));
|
||||
if_request.cmd = ADD_VLAN_CMD;
|
||||
if_request.u.VID = vid;
|
||||
|
||||
|
|
@ -1769,7 +1769,7 @@ nm_system_iface_compat_rem_vlan_device (const char *iface)
|
|||
}
|
||||
|
||||
memset (&if_request, 0, sizeof (struct vlan_ioctl_args));
|
||||
strcpy (if_request.device1, iface);
|
||||
g_strlcpy (if_request.device1, iface, sizeof (if_request.device1));
|
||||
if_request.cmd = DEL_VLAN_CMD;
|
||||
|
||||
if (ioctl (fd, SIOCSIFVLAN, &if_request) < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue