Skip to contentSkip to conversation

bnx2x: use strlcpy() to copy a string

PATCH Applied Dan Carpenter 2 participants 2 messages Oct 2, 2012 – Oct 3, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bnx2x: use strlcpy() to copy a string

DRV_MODULE_VERSION is smaller than the ->version buffer so the memcpy() copies 1 byte past the end of the string. It's not super harmful, but it makes the static checkers complain.

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +2 -3
index f7ed122..d5648fc 100644
@@ -3052,9 +3052,8 @@ static void bnx2x_drv_info_ether_stat(struct bnx2x *bp)
 	struct eth_stats_info *ether_stat  		&bp->slowpath->drv_info_to_mcp.ether_stat;
 
-	/* leave last char as NULL */
-	memcpy(ether_stat->version, DRV_MODULE_VERSION,
-	       ETH_STAT_INFO_VERSION_LEN - 1);
+	strlcpy(ether_stat->version, DRV_MODULE_VERSION,
+		ETH_STAT_INFO_VERSION_LEN);
 
 	bp->sp_objs[0].mac_obj.get_n_elements(bp, &bp->sp_objs[0].mac_obj,
 					DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED,
maintainer Applied
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Tue, 2 Oct 2012 14:47:46 +0300

Quoted 5 lines

DRV_MODULE_VERSION is smaller than the ->version buffer so the memcpy() copies 1 byte past the end of the string. It's not super harmful, but it makes the static checkers complain.

Applied, thanks Dan.