diff options
author | Johannes Stezenbach <js@sig21.net> | 2012-06-06 18:04:59 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-06-07 19:31:33 +0200 |
commit | 79f9683b8e3861d735714d216afad840a6e7ebd0 (patch) | |
tree | 691ad6987cb71ab5185b0d7d2d37a10a3f96a33f /fs | |
parent | 9c865c1669d4459145d66f3bf6130dd0cdb6f373 (diff) | |
download | barebox-79f9683b8e3861d735714d216afad840a6e7ebd0.tar.gz barebox-79f9683b8e3861d735714d216afad840a6e7ebd0.tar.xz |
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 <js@sig21.net>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/devfs.c | 3 |
1 files changed, 3 insertions, 0 deletions
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); } |