From 5d5a7f80d905d58530c8473bc7ec0b0b3b165658 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 8 Nov 2014 15:45:00 -0800 Subject: Replace last strcpy call + manual append with snprintf call Signed-off-by: Alan Coopersmith --- config.c | 8 +++----- 1 file 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 { -- cgit v1.2.3