]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
crash at startup when an empty suffix is supplied to --conf-dir
authorSimon Kelley <simon@thekelleys.org.uk>
Thu, 2 Oct 2014 20:44:21 +0000 (21:44 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Thu, 2 Oct 2014 20:44:21 +0000 (21:44 +0100)
CHANGELOG
src/option.c

index 768e2aaca42a00ea1f51fb91735088f7898bb2ad..13ab41c05fc3349b4b126dcd72b1f0470c4c8ea1 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+version 2.73
+            Fix crash at startup when an empty suffix is supplied to
+           --conf-dir, also trivial memory leak. Thanks to 
+           Tomas Hozza for spotting this.
+       
+
 version 2.72
             Add ra-advrouter mode, for RFC-3775 mobile IPv6 support.
 
index 45d8875fb7f9cce5d71016e7331c927fbdbf246c..b08e98e16f842e450be2af4b483a393b3b2fef48 100644 (file)
@@ -1474,22 +1474,25 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
        for (arg = comma; arg; arg = comma) 
          {
            comma = split(arg);
-           li = opt_malloc(sizeof(struct list));
-           if (*arg == '*')
+           if (strlen(arg) != 0)
              {
-               li->next = match_suffix;
-               match_suffix = li;
-               /* Have to copy: buffer is overwritten */
-               li->suffix = opt_string_alloc(arg+1);
-             }
-           else
-             {
-               li->next = ignore_suffix;
-               ignore_suffix = li;
-               /* Have to copy: buffer is overwritten */
-               li->suffix = opt_string_alloc(arg);
+               li = opt_malloc(sizeof(struct list));
+               if (*arg == '*')
+                 {
+                   li->next = match_suffix;
+                   match_suffix = li;
+                   /* Have to copy: buffer is overwritten */
+                   li->suffix = opt_string_alloc(arg+1);
+                 }
+               else
+                 {
+                   li->next = ignore_suffix;
+                   ignore_suffix = li;
+                   /* Have to copy: buffer is overwritten */
+                   li->suffix = opt_string_alloc(arg);
+                 }
              }
-         };
+         }
        
        if (!(dir_stream = opendir(directory)))
          die(_("cannot access directory %s: %s"), directory, EC_FILE);
@@ -1555,7 +1558,12 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
            free(ignore_suffix->suffix);
            free(ignore_suffix);
          }
-             
+       for(; match_suffix; match_suffix = li)
+         {
+           li = match_suffix->next;
+           free(match_suffix->suffix);
+           free(match_suffix);
+         }    
        break;
       }