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>
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.