# HG changeset patch # User Binki # Date 2009-05-31 23:33:35 # Node ID e9961eb67c98250bc47a96401ffa23c9285a79dc # Parent 7761d8ff26fad093ce55a68f70e6a82395b76ef6 corrected config file path finding I probably introduced some string management bugs = buffer overflows = death :-D 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)