diff options
author | Jan Weitzel <j.weitzel@phytec.de> | 2013-06-24 09:30:45 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-06-24 21:43:05 +0200 |
commit | fc01f5db567a4f423be2dac6e14e468cd78d79dc (patch) | |
tree | 1be72923d39cb16fe1e0ad66a0fd31c907fc7eec /commands | |
parent | d10f26a5ffc2ef636feff57a01fc89b002fc6c22 (diff) | |
download | barebox-fc01f5db567a4f423be2dac6e14e468cd78d79dc.tar.gz barebox-fc01f5db567a4f423be2dac6e14e468cd78d79dc.tar.xz |
ubiformat: check file size
If size of a flash image file is 0 ubiformat silently formats the volume.
Check size and abort if size == 0. This may be the case if an empty or tftp
mounted file is used.
Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/ubiformat.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/commands/ubiformat.c b/commands/ubiformat.c index 121816f4d7..5b4e5723f9 100644 --- a/commands/ubiformat.c +++ b/commands/ubiformat.c @@ -325,6 +325,11 @@ static int flash_image(const struct mtd_dev_info *mtd, goto out_close; } + if (st_size == 0) { + sys_errmsg("file \"%s\" has size 0 bytes", args.image); + goto out_close; + } + verbose(args.verbose, "will write %d eraseblocks", img_ebs); divisor = img_ebs; for (eb = 0; eb < mtd->eb_cnt; eb++) { |