Commit 949bbd7c867026e7f8ecb71abe6ebd113eda84d2
Committed by
Tom Rini
1 parent
6b367467f1
Exists in
v2017.01-smarct4x
and in
37 other branches
catch wrong load address passed to fatload / ext2load
If filename is passed instead of address to ext2load or fatload, u-boot silently accepts that, and uses 0 for load address and default filename from environment. That is confusing, display help instead. Signed-off-by: Pavel Machek <pavel@denx.de>
Showing 1 changed file with 4 additions and 1 deletions Side-by-side Diff
fs/fs.c
... | ... | @@ -276,6 +276,7 @@ |
276 | 276 | unsigned long pos; |
277 | 277 | int len_read; |
278 | 278 | unsigned long time; |
279 | + char *ep; | |
279 | 280 | |
280 | 281 | if (argc < 2) |
281 | 282 | return CMD_RET_USAGE; |
... | ... | @@ -286,7 +287,9 @@ |
286 | 287 | return 1; |
287 | 288 | |
288 | 289 | if (argc >= 4) { |
289 | - addr = simple_strtoul(argv[3], NULL, 16); | |
290 | + addr = simple_strtoul(argv[3], &ep, 16); | |
291 | + if (ep == argv[3] || *ep != '\0') | |
292 | + return CMD_RET_USAGE; | |
290 | 293 | } else { |
291 | 294 | addr_str = getenv("loadaddr"); |
292 | 295 | if (addr_str != NULL) |