summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdchar.c
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2014-07-21 19:08:13 -0700
committerBrian Norris <computersforpeace@gmail.com>2014-08-19 11:53:09 -0700
commit1cc8d8413327a684cd5e93cd52ececb0223bb40b (patch)
treec7d135bdbd80f8c84bfd29a0413f4d10ad1cfc6c /drivers/mtd/mtdchar.c
parent537ab1bd47d6518e8a40207a80dd0c2c4bc43aed (diff)
downloadlinux-stable-1cc8d8413327a684cd5e93cd52ececb0223bb40b.tar.gz
linux-stable-1cc8d8413327a684cd5e93cd52ececb0223bb40b.tar.bz2
linux-stable-1cc8d8413327a684cd5e93cd52ececb0223bb40b.zip
mtd: terminate user-provided string
Noticed by Coverity as a potential security issue. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r--drivers/mtd/mtdchar.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index a0f54e80670c..53563955931b 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -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: