diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-13 14:46:24 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-24 06:32:56 -0400 |
commit | a6ea440769e11c46828cddd20f91ab57261701d5 (patch) | |
tree | 19994608d2721de6484310c60e4a3ff1414cb1ef /drivers/mtd/ubi/cdev.c | |
parent | a5bf6190417cbbf80443a9f71c65b653e13e9982 (diff) |
UBI: improve mkvol request validation
Check that volume name is not shorter than 'name_len'.
No need to copy the trailing zero byte because whole array
was zeroed earlier.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/cdev.c')
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 3e3449ec07f0..4fb84e3e6502 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -574,6 +574,10 @@ static int verify_mkvol_req(const struct ubi_device *ubi, | |||
574 | goto bad; | 574 | goto bad; |
575 | } | 575 | } |
576 | 576 | ||
577 | n = strnlen(req->name, req->name_len + 1); | ||
578 | if (n != req->name_len) | ||
579 | goto bad; | ||
580 | |||
577 | return 0; | 581 | return 0; |
578 | 582 | ||
579 | bad: | 583 | bad: |
@@ -629,12 +633,11 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, | |||
629 | break; | 633 | break; |
630 | } | 634 | } |
631 | 635 | ||
636 | req.name[req.name_len] = '\0'; | ||
632 | err = verify_mkvol_req(ubi, &req); | 637 | err = verify_mkvol_req(ubi, &req); |
633 | if (err) | 638 | if (err) |
634 | break; | 639 | break; |
635 | 640 | ||
636 | req.name[req.name_len] = '\0'; | ||
637 | |||
638 | mutex_lock(&ubi->volumes_mutex); | 641 | mutex_lock(&ubi->volumes_mutex); |
639 | err = ubi_create_volume(ubi, &req); | 642 | err = ubi_create_volume(ubi, &req); |
640 | mutex_unlock(&ubi->volumes_mutex); | 643 | mutex_unlock(&ubi->volumes_mutex); |