Skip to contentSkip to conversation

mtd: terminate user-provided string

PATCH New Brian Norris 1 participant 1 message Jul 22, 2014 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: terminate user-provided string

Noticed by Coverity as a potential security issue.

---
Untested for now. Maybe I'll scrape together a test before applying, then it'd be worth sending -stable.

 drivers/mtd/mtdchar.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mtd/mtdchar.c +3 -0
index a0f54e80670c..53563955931b 100644
@@ -549,6 +549,9 @@ static int mtdchar_blkpg_ioctl(struct mtd_info *mtd,
 		if (mtd_is_partition(mtd))
 			return -EINVAL;
 
+		/* Sanitize user input */
+		p.devname[BLKPG_DEVNAMELTH - 1] = '\0';
+
 		return mtd_add_partition(mtd, p.devname, p.start, p.length);
 
 	case BLKPG_DEL_PARTITION:
Signature · 1 line
1.9.1