diff options
author | Thomas Weber <weber@corscience.de> | 2010-11-24 13:07:51 +0100 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2010-11-27 23:35:13 +0100 |
commit | 7013c06124e9760f75ef194d429ed29fba843eb9 (patch) | |
tree | 4fd24ea97e78fb6f140d15db2ff4e5f5b85f1837 /common/command.c | |
parent | 5904da021449c6d2404485dc1379bf0f3b33414a (diff) |
Common/command: Guard strchr/strlen from NULL pointer
Guard strchr/strlen from being called with NULL pointer.
This line is crashing when command "env" is called without subcommand.
The cmd is NULL in this case because the calling function "do_env"
decremented the argc without checking if there are still arguments available.
Signed-off-by: Thomas Weber <weber@corscience.de>
Diffstat (limited to 'common/command.c')
-rw-r--r-- | common/command.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/common/command.c b/common/command.c index 0020eacf5c4..0b1a3fbf9b1 100644 --- a/common/command.c +++ b/common/command.c @@ -108,6 +108,8 @@ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len) int len; int n_found = 0; + if (!cmd) + return NULL; /* * Some commands allow length modifiers (like "cp.b"); * compare command name only until first dot. |