Skip to contentSkip to conversation

mmc: use snprintf not sprintf

PATCH New Alan Cox 2 participants 2 messages Jun 17, 2010 – Aug 27, 2010 MMC, SD and SDIO

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 mmc: use snprintf not sprintf

Just starting on the MMC/SDIO patches in the Intel tree for upstream. This one is very much a take it or leave it item. Merge or drop ?

From: JiebingLi <[email protected]>

This patch fixes an issue found by klockwork. Just paranoia.

---

 drivers/mmc/card/block.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/card/block.c +2 -1
index cb9fbc8..9793f4c 100644
@@ -535,7 +535,8 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
 	 * messages to tell when the card is present.
 	 */
 
-	sprintf(md->disk->disk_name, "mmcblk%d", devidx);
+	snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
+		"mmcblk%d", devidx);
 
 	blk_queue_logical_block_size(md->queue.queue, 512);
 
#1 lore raw

PATCH RESEND 1/1 mmc: use snprintf not sprintf

Hi Alan,

This wasn't merged, because it went to Pierre rather than Andrew. Andrew, could you take it?

From: JiebingLi <[email protected]>
Date: Thu, 17 Jun 2010 15:58:46 +0100

This patch fixes an issue found by klockwork. Just paranoia.

---

 drivers/mmc/card/block.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/card/block.c +2 -1
index cb9fbc8..9793f4c 100644
@@ -535,7 +535,8 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
 	 * messages to tell when the card is present.
 	 */
 
-	sprintf(md->disk->disk_name, "mmcblk%d", devidx);
+	snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
+		"mmcblk%d", devidx);
 
 	blk_queue_logical_block_size(md->queue.queue, 512);
 

--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child