Skip to contentSkip to conversation

fsl/sata: Replace sprintf() with snprintf()

PATCH New Yuantian.Tang at freescale.com 1 participant 1 message May 6, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsl/sata: Replace sprintf() with snprintf()

From: Tang Yuantian <[email protected]>

Function 'sprintf' does not check buffer boundaries but outputs to the buffer of fixed size which could cause buffer overflow. Use a safer function to replace it.

---
 drivers/block/fsl_sata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/fsl_sata.c +1 -1
index 71d7cec..e720c3e 100644
@@ -113,7 +113,7 @@ int init_sata(int dev)
 	/* Save the private struct to block device struct */
 	sata_dev_desc[dev].priv = (void *)sata;
 
-	sprintf(sata->name, "SATA%d", dev);
+	snprintf(sata->name, 7, "SATA%d", dev);
 
 	/* Set the controller register base address to device struct */
 	reg = (fsl_sata_reg_t *)(fsl_sata_info[dev].sata_reg_base);
Signature · 1 line
2.1.0.27.g96db324