Changeset - e9961eb67c98
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-05-31 23:33:35
ohnobinki@ohnopublishing.net
corrected config file path finding
I probably introduced some string management bugs = buffer overflows = death :-D
1 file changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/common/options.c
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)