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>
This commit is contained in:
parent
03ddca6f71
commit
780133f9ae
|
@ -149,13 +149,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
|
|||
cmdsize = strlen(path) + 1;
|
||||
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. */
|
||||
|
|
Loading…
Reference in New Issue
Block a user