Skip to content
Snippets Groups Projects
Commit 454e3d90 authored by Stefan Brüns's avatar Stefan Brüns Committed by Tom Rini
Browse files

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: default avatarStefan Brüns <stefan.bruens@rwth-aachen.de>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
parent ae1755be
Branches
Tags
No related merge requests found
......@@ -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'"
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment