diff options
author | Kees Cook <keescook@chromium.org> | 2021-06-02 13:58:20 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-06-03 14:16:14 -0700 |
commit | 43902070fb7b73a0148eef63f5ece3a100e821ae (patch) | |
tree | 203969b734ff7f3a4ea0fe55383cc2d8bc431712 /drivers/net/bonding/bond_options.c | |
parent | 9c153d3889767eb347a9b1719cc6f336faccdba9 (diff) | |
download | linux-43902070fb7b73a0148eef63f5ece3a100e821ae.tar.gz linux-43902070fb7b73a0148eef63f5ece3a100e821ae.tar.bz2 linux-43902070fb7b73a0148eef63f5ece3a100e821ae.zip |
net: bonding: Use strscpy_pad() instead of manually-truncated strncpy()
Silence this warning by using strscpy_pad() directly:
drivers/net/bonding/bond_main.c:4877:3: warning: 'strncpy' specified bound 16 equals destination size [-Wstringop-truncation]
4877 | strncpy(params->primary, primary, IFNAMSIZ);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Additionally replace other strncpy() uses, as it is considered deprecated:
https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/202102150705.fdR6obB0-lkp@intel.com
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_options.c')
-rw-r--r-- | drivers/net/bonding/bond_options.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index c9d3604ae129..81c039531e66 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -1206,8 +1206,7 @@ static int bond_option_primary_set(struct bonding *bond, RCU_INIT_POINTER(bond->primary_slave, NULL); bond_select_active_slave(bond); } - strncpy(bond->params.primary, primary, IFNAMSIZ); - bond->params.primary[IFNAMSIZ - 1] = 0; + strscpy_pad(bond->params.primary, primary, IFNAMSIZ); netdev_dbg(bond->dev, "Recording %s as primary, but it has not been enslaved yet\n", primary); |