summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-09-11 22:51:42 +0200
committerTom Rini <trini@konsulko.com>2016-09-23 08:55:58 -0400
commit454e3d90302d52b619e6df7ebbe716964cee016e (patch)
tree0a3b6842212e744950922c66cf48d65870350e60
parentae1755be37e3d51af631ff2df12189c9fdc3e1d7 (diff)
cmd/fat: Do not crash on write when <bytes> is not specified
argc is checked, but is off by one. In case <bytes> is not specified, create an empty file, which is identical to the ext4write behaviour. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--cmd/fat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/fat.c b/cmd/fat.c
index 4e207462d93..ad1dc2a49f1 100644
--- a/cmd/fat.c
+++ b/cmd/fat.c
@@ -126,7 +126,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
return 1;
}
addr = simple_strtoul(argv[3], NULL, 16);
- count = simple_strtoul(argv[5], NULL, 16);
+ count = (argc <= 5) ? 0 : simple_strtoul(argv[5], NULL, 16);
buf = map_sysmem(addr, count);
ret = file_fat_write(argv[4], buf, 0, count, &size);
@@ -145,7 +145,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
U_BOOT_CMD(
fatwrite, 6, 0, do_fat_fswrite,
"write file into a dos filesystem",
- "<interface> <dev[:part]> <addr> <filename> <bytes>\n"
+ "<interface> <dev[:part]> <addr> <filename> [<bytes>]\n"
" - write file 'filename' from the address 'addr' in RAM\n"
" to 'dev' on 'interface'"
);