9
0
Fork 0

mem md: make md -s /dev/something work again

Since

|commit d22b85a203
|Author: Sascha Hauer <s.hauer@pengutronix.de>
|Date:   Wed Jul 4 23:41:13 2012 +0200
|
|    mem md: bail out without arguments
|
|    Without arguments the 'md' command defaults to show address 0 which
|    likely results in a NULL pointer exception, so only three keystrokes
|    are necessary to crash barebox. Show usage instead if 'md' is invoked
|    without arguments, so that it at least requires an address to be given
|    to crash barebox. This increases the stability of barebox by 66%. Hurray!

barebox does not crash any longer when a plain 'md' without additional arguments
is exectuted. However, doing a 'md -s /dev/nor0' was a standard usecase which now
does not work anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2012-07-31 17:34:39 +02:00
parent e8bbacab05
commit 239fa8cc9b
1 changed files with 3 additions and 2 deletions

View File

@ -170,6 +170,9 @@ static int do_mem_md(int argc, char *argv[])
char *filename = DEVMEM;
int mode = O_RWSIZE_4;
if (argc < 2)
return COMMAND_ERROR_USAGE;
if (mem_parse_options(argc, argv, "bwls:", &mode, &filename, NULL) < 0)
return 1;
@ -180,8 +183,6 @@ static int do_mem_md(int argc, char *argv[])
}
if (size == ~0)
size = 0x100;
} else {
return COMMAND_ERROR_USAGE;
}
fd = open_and_lseek(filename, mode | O_RDONLY, start);