Selaa lähdekoodia

* Ported [2660] to 1.2.9 (Conf memory leaks, datadir added to cmd_conf)

svn: 2661
Bryan Drewery 20 vuotta sitten
vanhempi
commit
846fd5a748
3 muutettua tiedostoa jossa 13 lisäystä ja 13 poistoa
  1. 2 0
      src/cmds.c
  2. 10 13
      src/conf.c
  3. 1 0
      src/main.c

+ 2 - 0
src/cmds.c

@@ -1698,6 +1698,7 @@ static void cmd_conf(int idx, char *par)
         if (!egg_strcasecmp(what, "homedir"))   str_redup(&conf.homedir, par);
         else if (!egg_strcasecmp(what, "binpath"))   str_redup(&conf.binpath, par);
         else if (!egg_strcasecmp(what, "binname"))   str_redup(&conf.binname, par);
+        else if (!egg_strcasecmp(what, "datadir"))   str_redup(&conf.datadir, par);
         else if (!egg_strcasecmp(what, "portmin"))   conf.portmin = atoi(par);
         else if (!egg_strcasecmp(what, "portmax"))   conf.portmax = atoi(par);
         else if (!egg_strcasecmp(what, "pscloak"))   conf.pscloak = atoi(par);
@@ -1721,6 +1722,7 @@ static void cmd_conf(int idx, char *par)
       if (!what || !egg_strcasecmp(what, "homedir"))    dprintf(idx, "%shomedir: %s\n", ss, conf.homedir);
       if (!what || !egg_strcasecmp(what, "binpath"))    dprintf(idx, "%sbinpath: %s\n", ss, conf.binpath);
       if (!what || !egg_strcasecmp(what, "binname"))    dprintf(idx, "%sbinname: %s\n", ss, conf.binname);
+      if (!what || !egg_strcasecmp(what, "datadir"))    dprintf(idx, "%sdatadir: %s\n", ss, conf.datadir);
       if (!what || !egg_strcasecmp(what, "portmin"))    dprintf(idx, "%sportmin: %d\n", ss, conf.portmin);
       if (!what || !egg_strcasecmp(what, "portmax"))    dprintf(idx, "%sportmax: %d\n", ss, conf.portmax);
       if (!what || !egg_strcasecmp(what, "pscloak"))    dprintf(idx, "%spscloak: %d\n", ss, conf.pscloak);

+ 10 - 13
src/conf.c

@@ -688,13 +688,13 @@ readconf(const char *fname, int bits)
             conf.autouname = atoi(line);
 
         } else if (!strcmp(option, "username")) {       /* shell username */
-          conf.username = strdup(line);
+          str_redup(&conf.username, line);
 
         } else if (!strcmp(option, "homedir")) {        /* homedir */
-          conf.homedir = strdup(line);
+          str_redup(&conf.homedir, line);
 
         } else if (!strcmp(option, "datadir")) {        /* datadir */
-          conf.datadir = strdup(line);
+          str_redup(&conf.datadir, line);
 
         } else if (!strcmp(option, "binpath")) {        /* path that the binary should move to? */
           str_redup(&conf.binpath, line);
@@ -719,10 +719,7 @@ readconf(const char *fname, int bits)
             conf.uid = atoi(line);
 
         } else if (!strcmp(option, "uname")) {  /* new method uname */
-          if (!conf.uname)
-            conf.uname = strdup(line);
-          else
-            str_redup(&conf.uname, line);
+          str_redup(&conf.uname, line);
 
         } else if (!strcmp(option, "watcher")) {
           if (egg_isdigit(line[0]))
@@ -1021,14 +1018,14 @@ bin_to_conf(void)
 {
 /* printf("Converting binary data to conf struct\n"); */
   conf.uid = atol(settings.uid);
-  conf.username = strdup(settings.username);
-  conf.uname = strdup(settings.uname);
-  conf.datadir = strdup(settings.datadir);
+  str_redup(&conf.username, settings.username);
+  str_redup(&conf.uname, settings.uname); 
+  str_redup(&conf.datadir, settings.datadir);
   expand_tilde(&conf.datadir);
-  conf.homedir = strdup(settings.homedir);
-  conf.binpath = strdup(settings.binpath);
+  str_redup(&conf.homedir, settings.homedir);
+  str_redup(&conf.binpath, settings.binpath);
   expand_tilde(&conf.binpath);
-  conf.binname = strdup(settings.binname);
+  str_redup(&conf.binname, settings.binname);
   conf.portmin = atol(settings.portmin);
   conf.portmax = atol(settings.portmax);
   conf.autouname = atoi(settings.autouname);

+ 1 - 0
src/main.c

@@ -380,6 +380,7 @@ static void dtx_arg(int argc, char *argv[])
 	printf("%s\nBuild Date: %s (%s%lu%s)\n", version, date, BOLD(-1), buildts, BOLD_END(-1));
         printf("Revision: %s\n", revision);
 	sdprintf("pack: %d conf: %d settings_t: %d pad: %d\n", SIZE_PACK, SIZE_CONF, sizeof(settings_t), SIZE_PAD);
+        /* This is simply to display the binary config */
         if (settings.uname[0]) {
           sdebug++;
           bin_to_conf();