mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Johannes Stezenbach <js@sig21.net>
To: barebox@lists.infradead.org
Subject: [PATCH 4/5] devfs: don't erase past the end of the partition
Date: Wed,  6 Jun 2012 18:04:59 +0200	[thread overview]
Message-ID: <1338998700-23012-5-git-send-email-js@sig21.net> (raw)
In-Reply-To: <1338998700-23012-1-git-send-email-js@sig21.net>

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

Signed-off-by: Johannes Stezenbach <js@sig21.net>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-06-06 16:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-06 16:04 [PATCH 0/5] minor SPI flash fixes Johannes Stezenbach
2012-06-06 16:04 ` [PATCH 1/5] m25p80: prevent endless loop in erase Johannes Stezenbach
2012-06-06 16:04 ` [PATCH 2/5] m25p80: allow erase to be interrupted Johannes Stezenbach
2012-06-06 16:04 ` [PATCH 3/5] m25p80: progressbar tweak Johannes Stezenbach
2012-06-06 16:04 ` Johannes Stezenbach [this message]
2012-06-06 16:05 ` [PATCH 5/5] fs: limit flash erase and protect to the partiton boundary Johannes Stezenbach
2012-06-07 17:32 ` [PATCH 0/5] minor SPI flash fixes Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338998700-23012-5-git-send-email-js@sig21.net \
    --to=js@sig21.net \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox