Thread (7 messages) flat view 7 messages, 3 authors, 2021-06-14

Re: [PATCH v1 2/2] net: ethernet: mtk_eth_soc: Support custom ifname

From: Reto Schneider <hidden>
Date: 2021-06-13 13:54:02
Also in: linux-arm-kernel, linux-devicetree, lkml, netdev

Hi Russell,

On 13.06.21 14:20, Russell King (Oracle) wrote:
Please don't use strncpy() - this is a good example why strncpy() is bad
news.

  * strncpy - Copy a length-limited, C-string
  * @dest: Where to copy the string to
  * @src: Where to copy the string from
  * @count: The maximum number of bytes to copy
  *
  * The result is not %NUL-terminated if the source exceeds
  * @count bytes.

Consequently, if "name" is IFNAMSIZ bytes or longer,
eth->netdev[id]->name will not be NUL terminated, and subsequent use
will run off the end of the string. strscpy() is safer to use here.
Thanks a lot for finding this (embarrassing mistake) and pointing me in 
the right direction (did dot know about strscpy).

Will send v2 soon.

Kind regards,
Reto

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help