]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Improve memory debug for dumping leases.
authorRoy Marples <roy@marples.name>
Tue, 24 Aug 2010 09:34:21 +0000 (09:34 +0000)
committerRoy Marples <roy@marples.name>
Tue, 24 Aug 2010 09:34:21 +0000 (09:34 +0000)
dhcpcd.c
if-options.c

index fe5fa1a7c097a7067b9af3b2718b42b8dd54987c..50ce393821d3a00e7ba9124b80bb9965a0a52941 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -88,6 +88,7 @@ char **ifdv = NULL;
 
 static char **margv;
 static int margc;
+static struct if_options *if_options;
 static char **ifv;
 static int ifc;
 static char *cffile;
@@ -161,6 +162,8 @@ cleanup(void)
        struct interface *iface;
        int i;
 
+       free_options(if_options);
+
        while (ifaces) {
                iface = ifaces;
                ifaces = iface->next;
@@ -1663,7 +1666,6 @@ close_sockets(struct interface *iface)
 int
 main(int argc, char **argv)
 {
-       struct if_options *ifo;
        struct interface *iface;
        int opt, oi = 0, signal_fd, sig = 0, i, control_fd;
        size_t len;
@@ -1721,14 +1723,14 @@ main(int argc, char **argv)
 
        margv = argv;
        margc = argc;
-       ifo = read_config(cffile, NULL, NULL, NULL);
-       opt = add_options(ifo, argc, argv);
+       if_options = read_config(cffile, NULL, NULL, NULL);
+       opt = add_options(if_options, argc, argv);
        if (opt != 1) {
                if (opt == 0)
                        usage();
                exit(EXIT_FAILURE);
        }
-       options = ifo->options;
+       options = if_options->options;
        if (i != 0) {
                if (i == 1)
                        options |= DHCPCD_TEST;
@@ -1769,7 +1771,7 @@ main(int argc, char **argv)
                        syslog(LOG_ERR, "dumplease requires an interface");
                        exit(EXIT_FAILURE);
                }
-               iface = xzalloc(sizeof(*iface));
+               ifaces = iface = xzalloc(sizeof(*iface));
                strlcpy(iface->name, argv[optind], sizeof(iface->name));
                snprintf(iface->leasefile, sizeof(iface->leasefile),
                    LEASEFILE, iface->name);
@@ -1896,7 +1898,7 @@ main(int argc, char **argv)
                syslog(LOG_ERR, "init_socket: %m");
                exit(EXIT_FAILURE);
        }
-       if (ifo->options & DHCPCD_LINK) {
+       if (if_options->options & DHCPCD_LINK) {
                linkfd = open_link_socket();
                if (linkfd == -1)
                        syslog(LOG_ERR, "open_link_socket: %m");
@@ -1968,14 +1970,15 @@ main(int argc, char **argv)
                {
                        syslog(LOG_WARNING, "no interfaces have a carrier");
                        daemonise();
-               } else if (ifo->timeout > 0) {
+               } else if (if_options->timeout > 0) {
                        if (options & DHCPCD_IPV4LL)
                                options |= DHCPCD_TIMEOUT_IPV4LL;
-                       add_timeout_sec(ifo->timeout, handle_exit_timeout,
-                           NULL);
+                       add_timeout_sec(if_options->timeout,
+                           handle_exit_timeout, NULL);
                }
        }
-       free_options(ifo);
+       free_options(if_options);
+       if_options = NULL;
 
        sort_interfaces();
        for (iface = ifaces; iface; iface = iface->next)
index 3367b4154343ab4924bd60aced11c470dc61701f..ae988bdd4383f2852a3d0c682baa9ec3c55bb60c 100644 (file)
@@ -132,6 +132,7 @@ add_environ(struct if_options *ifo, const char *value, int uniq)
        size_t i = 0, l, lv;
        char *match = NULL, *p;
 
+       return NULL;
        match = xstrdup(value);
        p = strchr(match, '=');
        if (p)