diff mbox series

[20/25] net: mdio-uclass: rewrite dm_mdio_post_probe using strlcpy

Message ID 20210927112205.301876-21-vladimir.oltean@nxp.com
State Accepted
Commit bf35c3121aa58eec03990bd5bd83ad1576106046
Delegated to: Ramon Fried
Headers show
Series Fix some non-NULL terminated strings in the networking subsystem | expand

Commit Message

Vladimir Oltean Sept. 27, 2021, 11:22 a.m. UTC
dm_mdio_post_probe used to be vulnerable after truncation, but has been
patched by commit 398e7512d8d7 ("net: Fix Covarity Defect 244093").
Nonetheless, we can use strlcpy like the rest of the code base now,
which yields the same result.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/mdio-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ramon Fried Sept. 28, 2021, 1:33 p.m. UTC | #1
On Mon, Sep 27, 2021 at 2:22 PM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> dm_mdio_post_probe used to be vulnerable after truncation, but has been
> patched by commit 398e7512d8d7 ("net: Fix Covarity Defect 244093").
> Nonetheless, we can use strlcpy like the rest of the code base now,
> which yields the same result.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  net/mdio-uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
> index 1b687765b8ca..e74e34f78f9c 100644
> --- a/net/mdio-uclass.c
> +++ b/net/mdio-uclass.c
> @@ -101,7 +101,7 @@ static int dm_mdio_post_probe(struct udevice *dev)
>         pdata->mii_bus->write = mdio_write;
>         pdata->mii_bus->reset = mdio_reset;
>         pdata->mii_bus->priv = dev;
> -       strncpy(pdata->mii_bus->name, dev->name, MDIO_NAME_LEN - 1);
> +       strlcpy(pdata->mii_bus->name, dev->name, MDIO_NAME_LEN);
>
>         return mdio_register(pdata->mii_bus);
>  }
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index 1b687765b8ca..e74e34f78f9c 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -101,7 +101,7 @@  static int dm_mdio_post_probe(struct udevice *dev)
 	pdata->mii_bus->write = mdio_write;
 	pdata->mii_bus->reset = mdio_reset;
 	pdata->mii_bus->priv = dev;
-	strncpy(pdata->mii_bus->name, dev->name, MDIO_NAME_LEN - 1);
+	strlcpy(pdata->mii_bus->name, dev->name, MDIO_NAME_LEN);
 
 	return mdio_register(pdata->mii_bus);
 }