Patchwork [net-next] team: use strlcpy with ethtool_drvinfo fields

login
register
mail settings
Submitter Flavio Leitner
Date Jan. 5, 2013, 12:53 p.m.
Message ID <1357390390-16549-1-git-send-email-fbl@redhat.com>
Download mbox | patch
Permalink /patch/209669/
State Accepted
Delegated to: David Miller
Headers show

Comments

Flavio Leitner - Jan. 5, 2013, 12:53 p.m.
The fields must be null-terminated.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
---
 drivers/net/team/team.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Jiri Pirko - Jan. 5, 2013, 1:17 p.m.
Sat, Jan 05, 2013 at 01:53:10PM CET, fbl@redhat.com wrote:
>The fields must be null-terminated.
>
>Signed-off-by: Flavio Leitner <fbl@redhat.com>
>---
> drivers/net/team/team.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
>index 78c7d87..e27ac5c 100644
>--- a/drivers/net/team/team.c
>+++ b/drivers/net/team/team.c
>@@ -1747,8 +1747,8 @@ static const struct net_device_ops team_netdev_ops = {
> static void team_ethtool_get_drvinfo(struct net_device *dev,
> 				     struct ethtool_drvinfo *drvinfo)
> {
>-	strncpy(drvinfo->driver, DRV_NAME, 32);
>-	strncpy(drvinfo->version, UTS_RELEASE, 32);
>+	strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
>+	strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version));
> }
> 
> static const struct ethtool_ops team_ethtool_ops = {
>-- 
>1.8.0.1
>


Acked-by: Jiri Pirko <jiri@resnulli.us>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Hutchings - Jan. 5, 2013, 2:11 p.m.
On Sat, 2013-01-05 at 10:53 -0200, Flavio Leitner wrote:
> The fields must be null-terminated.
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>

Acked-by: Ben Hutchings <bhutchings@solarflare.com>

> ---
>  drivers/net/team/team.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
> index 78c7d87..e27ac5c 100644
> --- a/drivers/net/team/team.c
> +++ b/drivers/net/team/team.c
> @@ -1747,8 +1747,8 @@ static const struct net_device_ops team_netdev_ops = {
>  static void team_ethtool_get_drvinfo(struct net_device *dev,
>  				     struct ethtool_drvinfo *drvinfo)
>  {
> -	strncpy(drvinfo->driver, DRV_NAME, 32);
> -	strncpy(drvinfo->version, UTS_RELEASE, 32);
> +	strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
> +	strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version));
>  }
>  
>  static const struct ethtool_ops team_ethtool_ops = {
David Miller - Jan. 7, 2013, 5:12 a.m.
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Sat, 5 Jan 2013 14:11:17 +0000

> On Sat, 2013-01-05 at 10:53 -0200, Flavio Leitner wrote:
>> The fields must be null-terminated.
>> 
>> Signed-off-by: Flavio Leitner <fbl@redhat.com>
> 
> Acked-by: Ben Hutchings <bhutchings@solarflare.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 78c7d87..e27ac5c 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1747,8 +1747,8 @@  static const struct net_device_ops team_netdev_ops = {
 static void team_ethtool_get_drvinfo(struct net_device *dev,
 				     struct ethtool_drvinfo *drvinfo)
 {
-	strncpy(drvinfo->driver, DRV_NAME, 32);
-	strncpy(drvinfo->version, UTS_RELEASE, 32);
+	strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
+	strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version));
 }
 
 static const struct ethtool_ops team_ethtool_ops = {