From fc01f5db567a4f423be2dac6e14e468cd78d79dc Mon Sep 17 00:00:00 2001 From: Jan Weitzel Date: Mon, 24 Jun 2013 09:30:45 +0200 Subject: 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 Signed-off-by: Sascha Hauer --- commands/ubiformat.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'commands') 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++) { -- cgit v1.2.3