u-boot/drivers/net/mscc_eswitch
Vladimir Oltean 47aa50d7db net: dsa: felix: ensure mii_bus->name is NULL terminated after MDIO_NAME_LEN truncation
strncpy() simply bails out when copying a source string whose size
exceeds the destination string size, potentially leaving the destination
string unterminated.

One possible way to address is to pass MDIO_NAME_LEN - 1 and a
previously zero-initialized destination string, but this is more
difficult to maintain.

The chosen alternative is to use strlcpy(), which properly limits the
copy len in the (srclen >= size) case to "size - 1", and which is also
more efficient than the strncpy() byte-by-byte implementation by using
memcpy. The destination string returned by strlcpy() is always NULL
terminated.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2021-09-28 18:50:56 +03:00
..
felix_switch.c net: dsa: felix: ensure mii_bus->name is NULL terminated after MDIO_NAME_LEN truncation 2021-09-28 18:50:56 +03:00
jr2_switch.c dm: core: Add address translation in fdt_get_resource 2021-04-29 03:23:39 -07:00
Kconfig pci: Drop DM_PCI 2021-09-13 18:23:13 -04:00
luton_switch.c net: luton: remove address translation after ofnode_read_resource 2021-06-05 07:35:47 -06:00
Makefile drivers: net: Add Felix DSA switch driver 2021-02-16 12:38:36 -05:00
mscc_mac_table.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
mscc_mac_table.h net: mscc: Move mac_table_add function into different file. 2019-02-01 14:13:36 +01:00
mscc_miim.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
mscc_miim.h net: mscc: refactor mscc_miim 2019-07-15 13:32:25 -05:00
mscc_xfer.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
mscc_xfer.h net: mscc: Move ocelot_send and ocelot_recv in a different file. 2019-02-01 14:13:36 +01:00
ocelot_switch.c dm: core: Add address translation in fdt_get_resource 2021-04-29 03:23:39 -07:00
serval_switch.c dm: core: Add address translation in fdt_get_resource 2021-04-29 03:23:39 -07:00
servalt_switch.c dm: core: Add address translation in fdt_get_resource 2021-04-29 03:23:39 -07:00