Fixes for problems found by Coverity in the apps/ repository:

nshlib/nsh_parse.c: Avoid truncating the strcmp result into a unsigned char variable.

    nshlib/nsh_netcmds.c: Check for valid hostip before using it.

    nshlib/nsh_ddcmd.c: Fix resouce leak when 'if=' or 'of=' params are repeated in the command line.  For example:

       dd if=/dev/null if=/dev/zero of=/dev/null or
       dd if=/dev/zero of=/dev/zero of=/dev/null
This commit is contained in:
Bruno Herrera
2017-09-25 07:34:34 -06:00
committed by Gregory Nutt
parent 873e4ee83e
commit 3fe720d1e2
3 changed files with 29 additions and 16 deletions

View File

@@ -1497,10 +1497,10 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd,
{
/* Check if the command is preceded by "while" or "until" */
whilematch = strcmp(cmd, "while");
untilmatch = strcmp(cmd, "until");
whilematch = strcmp(cmd, "while") == 0;
untilmatch = strcmp(cmd, "until") == 0;
if (whilematch == 0 || untilmatch == 0)
if (whilematch || untilmatch)
{
uint8_t state;