From 79f9683b8e3861d735714d216afad840a6e7ebd0 Mon Sep 17 00:00:00 2001 From: Johannes Stezenbach Date: Wed, 6 Jun 2012 18:04:59 +0200 Subject: devfs: don't erase past the end of the partition "erase /dev/myflash0.mypart 0xf0000+0xf0000" could erase past the end of the partition. Signed-off-by: Johannes Stezenbach Signed-off-by: Sascha Hauer --- fs/devfs.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs/devfs.c') diff --git a/fs/devfs.c b/fs/devfs.c index e3a21ae795..ae48451b6c 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -73,6 +73,9 @@ static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, unsigned lo if (!cdev->ops->erase) return -ENOSYS; + if (count + offset > cdev->size) + count = cdev->size - offset; + return cdev->ops->erase(cdev, count, offset + cdev->offset); } -- cgit v1.2.3