diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-10-28 21:29:50 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-23 12:15:05 -0800 |
commit | 780133f9ae7fada462714b47e79d26075bbd9abe (patch) | |
tree | f07f870d9f30cdedb5e5cdd375efa14565a1b566 | |
parent | 03ddca6f71339fad089c56484bf35c63642ae1be (diff) |
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>
-rw-r--r-- | os/client.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/os/client.c b/os/client.c index b5349778b..4aec097e1 100644 --- a/os/client.c +++ b/os/client.c @@ -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. */ |