bridge: move from strlcpy with unused retval to strscpy

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://lore.kernel.org/r/20220818210212.8347-1-wsa+renesas@sang-engineering.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Wolfram Sang 2022-08-18 23:02:12 +02:00 committed by Jakub Kicinski
parent 6164b5e3bc
commit 993e1634ab
3 changed files with 7 additions and 7 deletions

View File

@ -251,10 +251,10 @@ static int br_set_mac_address(struct net_device *dev, void *p)
static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info) static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{ {
strlcpy(info->driver, "bridge", sizeof(info->driver)); strscpy(info->driver, "bridge", sizeof(info->driver));
strlcpy(info->version, BR_VERSION, sizeof(info->version)); strscpy(info->version, BR_VERSION, sizeof(info->version));
strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); strscpy(info->fw_version, "N/A", sizeof(info->fw_version));
strlcpy(info->bus_info, "N/A", sizeof(info->bus_info)); strscpy(info->bus_info, "N/A", sizeof(info->bus_info));
} }
static int br_get_link_ksettings(struct net_device *dev, static int br_get_link_ksettings(struct net_device *dev,

View File

@ -384,7 +384,7 @@ int br_sysfs_addif(struct net_bridge_port *p)
return err; return err;
} }
strlcpy(p->sysfs_name, p->dev->name, IFNAMSIZ); strscpy(p->sysfs_name, p->dev->name, IFNAMSIZ);
return sysfs_create_link(br->ifobj, &p->kobj, p->sysfs_name); return sysfs_create_link(br->ifobj, &p->kobj, p->sysfs_name);
} }
@ -406,7 +406,7 @@ int br_sysfs_renameif(struct net_bridge_port *p)
netdev_notice(br->dev, "unable to rename link %s to %s", netdev_notice(br->dev, "unable to rename link %s to %s",
p->sysfs_name, p->dev->name); p->sysfs_name, p->dev->name);
else else
strlcpy(p->sysfs_name, p->dev->name, IFNAMSIZ); strscpy(p->sysfs_name, p->dev->name, IFNAMSIZ);
return err; return err;
} }

View File

@ -1446,7 +1446,7 @@ static inline int ebt_obj_to_user(char __user *um, const char *_name,
/* ebtables expects 31 bytes long names but xt_match names are 29 bytes /* ebtables expects 31 bytes long names but xt_match names are 29 bytes
* long. Copy 29 bytes and fill remaining bytes with zeroes. * long. Copy 29 bytes and fill remaining bytes with zeroes.
*/ */
strlcpy(name, _name, sizeof(name)); strscpy(name, _name, sizeof(name));
if (copy_to_user(um, name, EBT_EXTENSION_MAXNAMELEN) || if (copy_to_user(um, name, EBT_EXTENSION_MAXNAMELEN) ||
put_user(revision, (u8 __user *)(um + EBT_EXTENSION_MAXNAMELEN)) || put_user(revision, (u8 __user *)(um + EBT_EXTENSION_MAXNAMELEN)) ||
put_user(datasize, (int __user *)(um + EBT_EXTENSION_MAXNAMELEN + 1)) || put_user(datasize, (int __user *)(um + EBT_EXTENSION_MAXNAMELEN + 1)) ||