diff options
author | Roy Marples <roy@marples.name> | 2007-04-06 01:04:07 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-04-06 01:04:07 +0000 |
commit | 657be653400bdb9fc8ab13037e51ecfbc1af9d40 (patch) | |
tree | 8e876d2a345eb56dff9b7c732a082bc00720d020 /src/rc.c | |
parent | 308042c87bd920d787265f1854bf1695bdbab8e4 (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.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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); |