Commit 454e3d90302d52b619e6df7ebbe716964cee016e
Committed by
Tom Rini
1 parent
ae1755be37
Exists in
v2017.01-smarct4x
and in
25 other branches
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>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
cmd/fat.c
... | ... | @@ -126,7 +126,7 @@ |
126 | 126 | return 1; |
127 | 127 | } |
128 | 128 | addr = simple_strtoul(argv[3], NULL, 16); |
129 | - count = simple_strtoul(argv[5], NULL, 16); | |
129 | + count = (argc <= 5) ? 0 : simple_strtoul(argv[5], NULL, 16); | |
130 | 130 | |
131 | 131 | buf = map_sysmem(addr, count); |
132 | 132 | ret = file_fat_write(argv[4], buf, 0, count, &size); |
... | ... | @@ -145,7 +145,7 @@ |
145 | 145 | U_BOOT_CMD( |
146 | 146 | fatwrite, 6, 0, do_fat_fswrite, |
147 | 147 | "write file into a dos filesystem", |
148 | - "<interface> <dev[:part]> <addr> <filename> <bytes>\n" | |
148 | + "<interface> <dev[:part]> <addr> <filename> [<bytes>]\n" | |
149 | 149 | " - write file 'filename' from the address 'addr' in RAM\n" |
150 | 150 | " to 'dev' on 'interface'" |
151 | 151 | ); |