Convert DetermineClientCmd to use strdup instead of malloc+strncpy

*cmdname is initialized to NULL earlier in the function, so it's
okay to overwrite it with NULL if strdup fails, don't need that
extra check.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 780133f9ae)
This commit is contained in:
Alan Coopersmith 2011-10-28 21:29:50 -07:00 committed by Jeremy Huddleston
parent 5b28bcb340
commit d2db5100b1

View file

@ -234,13 +234,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
/* Contruct the process name without arguments. */
if (cmdname)
{
char *name = malloc(cmdsize);
if (name)
{
strncpy(name, path, cmdsize);
name[cmdsize - 1] = '\0';
*cmdname = name;
}
*cmdname = strdup(path);
}
/* Construct the arguments for client process. */