sfc: Use strlcpy() to copy ethtool stats names
authorBen Hutchings <bhutchings@solarflare.com>
Mon, 2 Jul 2012 20:36:59 +0000 (21:36 +0100)
committerBen Hutchings <bhutchings@solarflare.com>
Tue, 17 Jul 2012 15:12:32 +0000 (16:12 +0100)
Fix CID 113703 in the Coverity report on Linux.

ethtool stats names are limited to 32 bytes including a null
terminator.  Use strlcpy() to ensure that we will always include the
null terminator even if a source string becomes longer than this.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
drivers/net/ethernet/sfc/ethtool.c

index 03ded364c8dab234f43437b629659821c3aa41b4..10536f93b5611d15a22a56b3ca280e0f107ea828 100644 (file)
@@ -453,7 +453,7 @@ static void efx_ethtool_get_strings(struct net_device *net_dev,
        switch (string_set) {
        case ETH_SS_STATS:
                for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++)
-                       strncpy(ethtool_strings[i].name,
+                       strlcpy(ethtool_strings[i].name,
                                efx_ethtool_stats[i].name,
                                sizeof(ethtool_strings[i].name));
                break;