summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-11-08 15:45:00 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-11-08 15:59:28 -0800
commit5d5a7f80d905d58530c8473bc7ec0b0b3b165658 (patch)
tree83544dd1f82127ccbfc2d44e879bac19b1f1ed09
parent9a17f21de44bcfe1493e9d10ae2354c2a3b496b1 (diff)
Replace last strcpy call + manual append with snprintf call
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--config.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/config.c b/config.c
index e11b855..8696ac5 100644
--- a/config.c
+++ b/config.c
@@ -158,17 +158,15 @@ GetConfig (
if (*managed)
{
- n = strlen (p);
- *startCommand = (char *) malloc (n + 2);
+ n = strlen (p) + 2;
+ *startCommand = (char *) malloc (n);
if (! *startCommand) {
fprintf (stderr,
"Memory allocation failed for service \"%s\"\n",
serviceName);
break;
}
- strcpy (*startCommand, p);
- (*startCommand)[n] = '&';
- (*startCommand)[n + 1] = '\0';
+ snprintf(*startCommand, n, "%s&", p);
}
else
{