Skip to content

Commit

Permalink
sh: Fix copying uninitialized field 'special'.
Browse files Browse the repository at this point in the history
This just copied uninitialized data and did not depend on it later, so it
should not be dangerous.

Found by:	clang static analyzer
  • Loading branch information
jillest committed Mar 13, 2016
1 parent 21613a5 commit adf4768
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/sh/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
if (strchr(name, '/') != NULL) {
entry->cmdtype = CMDNORMAL;
entry->u.index = 0;
entry->special = 0;
return;
}

Expand Down Expand Up @@ -408,6 +409,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
cmdp = &loc_cmd;
cmdp->cmdtype = CMDNORMAL;
cmdp->param.index = idx;
cmdp->special = 0;
INTON;
goto success;
}
Expand All @@ -420,6 +422,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
}
entry->cmdtype = CMDUNKNOWN;
entry->u.index = 0;
entry->special = 0;
return;

success:
Expand Down Expand Up @@ -588,6 +591,7 @@ addcmdentry(const char *name, struct cmdentry *entry)
}
cmdp->cmdtype = entry->cmdtype;
cmdp->param = entry->u;
cmdp->special = entry->special;
INTON;
}

Expand All @@ -604,6 +608,7 @@ defun(const char *name, union node *func)
INTOFF;
entry.cmdtype = CMDFUNCTION;
entry.u.func = copyfunc(func);
entry.special = 0;
addcmdentry(name, &entry);
INTON;
}
Expand Down

0 comments on commit adf4768

Please sign in to comment.