aboutsummaryrefslogtreecommitdiff
path: root/src/rc.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-06 01:04:07 +0000
committerRoy Marples <roy@marples.name>2007-04-06 01:04:07 +0000
commit657be653400bdb9fc8ab13037e51ecfbc1af9d40 (patch)
tree8e876d2a345eb56dff9b7c732a082bc00720d020 /src/rc.c
parent308042c87bd920d787265f1854bf1695bdbab8e4 (diff)
Misc fixes, plugged a memory leak in runscript.c and use va_copy to avoid nasty segfaults
Diffstat (limited to 'src/rc.c')
-rw-r--r--src/rc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/rc.c b/src/rc.c
index 12851c50..9b7d0edb 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -1013,19 +1013,22 @@ int main (int argc, char **argv)
/* Unless we would use a different config file */
if (found)
{
+ int len;
if (! newlevel)
continue;
-
- tmp = rc_xmalloc (strlen (service) + strlen (runlevel) + 2);
- sprintf (tmp, "%s.%s", service, runlevel);
+
+ len = strlen (service) + strlen (runlevel) + 2;
+ tmp = rc_xmalloc (sizeof (char *) * len);
+ snprintf (tmp, len, "%s.%s", service, runlevel);
conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
found = rc_exists (conf);
CHAR_FREE (conf);
CHAR_FREE (tmp);
if (! found)
{
- tmp = rc_xmalloc (strlen (service) + strlen (newlevel) + 2);
- sprintf (tmp, "%s.%s", service, newlevel);
+ len = strlen (service) + strlen (newlevel) + 2;
+ tmp = rc_xmalloc (sizeof (char *) * len);
+ snprintf (tmp, len, "%s.%s", service, newlevel);
conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
found = rc_exists (conf);
CHAR_FREE (conf);