[PATCH 4/5] devfs: don't erase past the end of the partition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"erase /dev/myflash0.mypart 0xf0000+0xf0000" could erase past
the end of the partition.

Signed-off-by: Johannes Stezenbach <js@xxxxxxxxx>
---
 fs/devfs.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/devfs.c b/fs/devfs.c
index e3a21ae..ae48451 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);
 }
 
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux