diff --git a/src/common/options.c b/src/common/options.c --- a/src/common/options.c +++ b/src/common/options.c @@ -34,15 +34,22 @@ int options_init(int argc, char *argv[], { char *configfile; + size_t i; + /* For those of you who don't know, the following is an example of concatenation of constant strings by the C compiler. Now, that doesn't mean you can do run-time string concatenation ;-) strdup is because someday configfile will be customizable via argv[] */ - configfile = strdup(SYSCONFDIR "/distren.conf"); + + i = strlen(SYSCONFDIR "/distren.conf") + strlen(myname) + 1; + configfile = malloc(i); if(!configfile) { - perror("strdup"); + perror("malloc"); return 1; } + strncpy(configfile, SYSCONFDIR "/distren", strlen(SYSCONFDIR "/distren") + 1); + strcat(configfile, myname); + strcat(configfile, ".conf"); *allopts = malloc(sizeof(struct options_common)); if(!*allopts)