Move all conf file stuff to talloc
authorAlan T. DeKok <aland@freeradius.org>
Mon, 18 Feb 2013 21:48:47 +0000 (16:48 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 19 Feb 2013 22:04:55 +0000 (17:04 -0500)
12 files changed:
src/include/conffile.h
src/main/client.c
src/main/conffile.c
src/main/connection.c
src/main/listen.c
src/main/mainconfig.c
src/main/modules.c
src/main/radclient.mk
src/main/radmin.mk
src/main/realms.c
src/main/tls.c
src/modules/rlm_eap/mem.c

index 1640ec4..d17e42d 100644 (file)
@@ -49,10 +49,8 @@ typedef struct CONF_PARSER {
 #define XStringify(x) #x
 #define Stringify(x) XStringify(x)
 
-void           cf_pair_free(CONF_PAIR **cp);
 int            cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp,
                                const char *value);
-void           cf_section_free(CONF_SECTION **cp);
 int            cf_item_parse(CONF_SECTION *cs, const char *name,
                              int type, void *data, const char *dflt);
 int            cf_section_parse(CONF_SECTION *, void *base,
@@ -60,6 +58,7 @@ int           cf_section_parse(CONF_SECTION *, void *base,
 void           cf_section_parse_free(CONF_SECTION *cs, void *base);
 const CONF_PARSER *cf_section_parse_table(CONF_SECTION *cs);
 CONF_SECTION   *cf_file_read(const char *file);
+void           cf_file_free(CONF_SECTION *cs);
 int            cf_file_include(const char *file, CONF_SECTION *cs);
 
 CONF_PAIR      *cf_pair_find(const CONF_SECTION *, const char *name);
index 9487a55..318169b 100644 (file)
@@ -96,19 +96,7 @@ void client_free(RADCLIENT *client)
        }
 #endif
 
-       free(client->longname);
-       free(client->secret);
-       free(client->shortname);
-       free(client->nastype);
-       free(client->login);
-       free(client->password);
-       free(client->server);
-
-#ifdef WITH_DYNAMIC_CLIENTS
-       free(client->client_server);
-#endif
-
-       free(client);
+       talloc_free(client);
 }
 
 /*
@@ -176,7 +164,7 @@ void clients_free(RADCLIENT_LIST *clients)
         */
 #endif
 
-       free(clients);
+       talloc_free(clients);
 }
 
 /*
@@ -184,7 +172,7 @@ void clients_free(RADCLIENT_LIST *clients)
  */
 RADCLIENT_LIST *clients_init(void)
 {
-       RADCLIENT_LIST *clients = calloc(1, sizeof(RADCLIENT_LIST));
+       RADCLIENT_LIST *clients = talloc_zero(NULL, RADCLIENT_LIST);
 
        if (!clients) return NULL;
 
@@ -589,8 +577,7 @@ static RADCLIENT *client_parse(CONF_SECTION *cs, int in_server)
        /*
         * The size is fine.. Let's create the buffer
         */
-       c = rad_malloc(sizeof(*c));
-       memset(c, 0, sizeof(*c));
+       c = talloc_zero(cs, RADCLIENT);
        c->cs = cs;
 
        memset(&cl_ip4addr, 0, sizeof(cl_ip4addr));
@@ -603,9 +590,7 @@ static RADCLIENT *client_parse(CONF_SECTION *cs, int in_server)
        error:
                client_free(c);
 #ifdef WITH_TCP
-               free(hs_proto);
                hs_proto = NULL;
-               free(cl_srcipaddr);
                cl_srcipaddr = NULL;
 #endif
 
@@ -705,16 +690,13 @@ static RADCLIENT *client_parse(CONF_SECTION *cs, int in_server)
 #ifdef WITH_TCP
                if (hs_proto) {
                        if (strcmp(hs_proto, "udp") == 0) {
-                               free(hs_proto);
                                hs_proto = NULL;
                                
                        } else if (strcmp(hs_proto, "tcp") == 0) {
-                               free(hs_proto);
                                hs_proto = NULL;
                                c->proto = IPPROTO_TCP;
                                
                        } else if (strcmp(hs_proto, "*") == 0) {
-                               free(hs_proto);
                                hs_proto = NULL;
                                c->proto = IPPROTO_IP; /* fake for dual */
                                
@@ -742,7 +724,6 @@ static RADCLIENT *client_parse(CONF_SECTION *cs, int in_server)
                DEBUGW("Server not build with udpfromto, ignoring client src_ipaddr");
 #endif
                
-               free(cl_srcipaddr);
                cl_srcipaddr = NULL;
        }
        
@@ -853,18 +834,6 @@ RADCLIENT_LIST *clients_parse_section(CONF_SECTION *section)
 
        if (strcmp("server", cf_section_name1(section)) == 0) in_server = TRUE;
 
-       /*
-        *      Associate the clients structure with the section, where
-        *      it will be freed once the section is freed.
-        */
-       if (cf_data_add(section, "clients", clients, (void *) clients_free) < 0) {
-               cf_log_err(cf_sectiontoitem(section),
-                          "Failed to associate clients with section %s",
-                      cf_section_name1(section));
-               clients_free(clients);
-               return NULL;
-       }
-
        for (cs = cf_subsection_find_next(section, NULL, "client");
             cs != NULL;
             cs = cf_subsection_find_next(section, cs, "client")) {
@@ -1080,8 +1049,7 @@ RADCLIENT *client_create(RADCLIENT_LIST *clients, REQUEST *request)
 
        if (!clients || !request) return NULL;
 
-       c = rad_malloc(sizeof(*c));
-       memset(c, 0, sizeof(*c));
+       c = talloc_zero(clients, RADCLIENT);
        c->cs = request->client->cs;
        c->ipaddr.af = AF_UNSPEC;
        c->src_ipaddr.af = AF_UNSPEC;
@@ -1150,9 +1118,9 @@ RADCLIENT *client_create(RADCLIENT_LIST *clients, REQUEST *request)
 
                case PW_TYPE_STRING_PTR:
                        p = (char **) ((char *) c + dynamic_config[i].offset);
-                       if (*p) free(*p);
+                       if (*p) talloc_free(*p);
                        if (vp->vp_strvalue[0]) {
-                               *p = strdup(vp->vp_strvalue);
+                               *p = talloc_strdup(c->cs, vp->vp_strvalue);
                        } else {
                                *p = NULL;
                        }
index 5ba0cad..568ccea 100644 (file)
@@ -137,13 +137,6 @@ CONF_ITEM *cf_sectiontoitem(CONF_SECTION *cs)
        return (CONF_ITEM *)cs;
 }
 
-static CONF_DATA *cf_itemtodata(CONF_ITEM *ci)
-{
-       if (ci == NULL)
-               return NULL;
-       rad_assert(ci->type == CONF_ITEM_DATA);
-       return (CONF_DATA *)ci;
-}
 static CONF_ITEM *cf_datatoitem(CONF_DATA *cd)
 {
        if (cd == NULL)
@@ -158,72 +151,44 @@ static CONF_PAIR *cf_pair_alloc(const char *attr, const char *value,
                                FR_TOKEN op, FR_TOKEN value_type,
                                CONF_SECTION *parent)
 {
-       char *p;
-       size_t attr_len, value_len = 0;
        CONF_PAIR *cp;
 
        if (!attr) return NULL;
-       attr_len = strlen(attr) + 1;
-       if (value) value_len = strlen(value) + 1;
 
-       p = rad_malloc(sizeof(*cp) + attr_len + value_len);
+       cp = talloc_zero(parent, CONF_PAIR);
+       if (!cp) return NULL;
 
-       cp = (CONF_PAIR *) p;
-       memset(cp, 0, sizeof(*cp));
        cp->item.type = CONF_ITEM_PAIR;
        cp->item.parent = parent;
+       cp->value_type = value_type;
+       cp->op = op;
 
-       p += sizeof(*cp);
-       memcpy(p, attr, attr_len);
-       cp->attr = p;
+       cp->attr = talloc_strdup(cp, attr);
+       if (!cp->attr) {
+       error:
+               talloc_free(cp);
+               return NULL;
+       }
 
        if (value) {
-               p += attr_len;
-               memcpy(p, value, value_len);
-               cp->value = p;
+               cp->value = talloc_strdup(cp, value);
+               if (!cp->value) goto error;
        }
-       cp->value_type = value_type;
-       cp->op = op;
 
        return cp;
 }
 
-/*
- *     Free a CONF_PAIR
- */
-void cf_pair_free(CONF_PAIR **cp)
+static int cf_data_free(void *ctx)
 {
-       if (!cp || !*cp) return;
-
-       /*
-        *      attr && value are allocated contiguous with cp.
-        */
+       CONF_DATA *cd;
 
-#ifndef NDEBUG
-       memset(*cp, 0, sizeof(cp));
-#endif
-       free(*cp);
+       cd = talloc_get_type_abort(ctx, CONF_DATA);
+       cd->free(cd->data);
 
-       *cp = NULL;
+       return 0;
 }
 
 
-static void cf_data_free(CONF_DATA **cd)
-{
-       if (!cd || !*cd) return;
-
-       /* name is allocated contiguous with cd */
-       if (!(*cd)->free) {
-               free((*cd)->data);
-       } else {
-               ((*cd)->free)((*cd)->data);
-       }
-#ifndef NDEBUG
-       memset(*cd, 0, sizeof(cd));
-#endif
-       free(*cd);
-       *cd = NULL;
-}
 
 /*
  *     rbtree callback function
@@ -283,146 +248,34 @@ static int data_cmp(const void *a, const void *b)
        return strcmp(one->name, two->name);
 }
 
-
-/*
- *     Free strings we've parsed into data structures.
- */
-void cf_section_parse_free(CONF_SECTION *cs, void *base)
-{
-       int i;
-       const CONF_PARSER *variables = cs->variables;
-
-       /*
-        *      Don't automatically free the strings if we're being
-        *      called from a module.  This is also for clients.c,
-        *      where client_free() expects to be able to free the
-        *      client structure.  If we moved everything to key off
-        *      of the config files, we might solve some problems...
-        */
-       if (!variables) return;
-
-       /*
-        *      Free up dynamically allocated string pointers.
-        */
-       for (i = 0; variables[i].name != NULL; i++) {
-               int type;
-               char **p;
-
-               type = variables[i].type & ~PW_TYPE_DEPRECATED;
-
-               if (type == PW_TYPE_SUBSECTION) {
-                       CONF_SECTION *subcs;
-                       subcs = cf_section_sub_find(cs, variables[i].name);
-
-                       if (!subcs) continue;
-
-                       if (!variables[i].dflt) continue;
-
-                       cf_section_parse_free(subcs, base);
-                       continue;
-               }
-
-               if ((type != PW_TYPE_STRING_PTR) &&
-                   (type != PW_TYPE_FILENAME)) {
-                       continue;
-               }
-
-               /*
-                *      No base struct offset, data must be the pointer.
-                *      If data doesn't exist, ignore the entry, there
-                *      must be something wrong.
-                */
-               if (!base) {
-                       if (!variables[i].data) {
-                               continue;
-                       }
-
-                       p = (char **) variables[i].data;;
-
-               } else if (variables[i].data) {
-                       p = (char **) variables[i].data;;
-
-               } else {
-                       p = (char **) (((char *)base) + variables[i].offset);
-               }
-
-               free(*p);
-               *p = NULL;
-       }
-
-       cs->variables = NULL;
-}
-
-
-/*
- *     Free a CONF_SECTION
- */
-void cf_section_free(CONF_SECTION **cs)
+static int cf_section_free(void *ctx)
 {
-       CONF_ITEM       *ci, *next;
-
-       if (!cs || !*cs) return;
-
-       cf_section_parse_free(*cs, (*cs)->base);
-
-       for (ci = (*cs)->children; ci; ci = next) {
-               next = ci->next;
-
-               switch (ci->type) {
-               case CONF_ITEM_PAIR: {
-                               CONF_PAIR *pair = cf_itemtopair(ci);
-                               cf_pair_free(&pair);
-                       }
-                       break;
-
-               case CONF_ITEM_SECTION: {
-                               CONF_SECTION *section = cf_itemtosection(ci);
-                               cf_section_free(&section);
-                       }
-                       break;
-
-               case CONF_ITEM_DATA: {
-                               CONF_DATA *data = cf_itemtodata(ci);
-                               cf_data_free(&data);
-                       }
-                       break;
+       CONF_SECTION *cs;
 
-               default:        /* should really be an error. */
-                       break;
-               }
-       }
-       (*cs)->children = NULL;
+       cs = talloc_get_type_abort(ctx, CONF_SECTION);
 
        /*
         *      Name1 and name2 are allocated contiguous with
         *      cs.
         */
-       if ((*cs)->pair_tree) {
-               rbtree_free((*cs)->pair_tree);
-               (*cs)->pair_tree = NULL;
+       if (cs->pair_tree) {
+               rbtree_free(cs->pair_tree);
+               cs->pair_tree = NULL;
        }
-       if ((*cs)->section_tree) {
-               rbtree_free((*cs)->section_tree);
-               (*cs)->section_tree = NULL;
+       if (cs->section_tree) {
+               rbtree_free(cs->section_tree);
+               cs->section_tree = NULL;
        }
-       if ((*cs)->name2_tree) {
-               rbtree_free((*cs)->name2_tree);
-               (*cs)->name2_tree = NULL;
+       if (cs->name2_tree) {
+               rbtree_free(cs->name2_tree);
+               cs->name2_tree = NULL;
        }
-       if ((*cs)->data_tree) {
-               rbtree_free((*cs)->data_tree);
-               (*cs)->data_tree = NULL;
+       if (cs->data_tree) {
+               rbtree_free(cs->data_tree);
+               cs->data_tree = NULL;
        }
 
-       /*
-        * And free the section
-        */
-#ifndef NDEBUG
-       memset(*cs, 0, sizeof(cs));
-#endif
-       free(*cs);
-
-       *cs = NULL;
+       return 0;
 }
 
 
@@ -432,14 +285,11 @@ void cf_section_free(CONF_SECTION **cs)
 static CONF_SECTION *cf_section_alloc(const char *name1, const char *name2,
                                      CONF_SECTION *parent)
 {
-       size_t name1_len, name2_len = 0;
-       char *p;
        CONF_SECTION    *cs;
        char buffer[1024];
 
        if (!name1) return NULL;
 
-       name1_len = strlen(name1) + 1;
        if (name2) {
                if (strchr(name2, '$')) {
                        name2 = cf_expand_variables(parent->item.filename,
@@ -451,31 +301,30 @@ static CONF_SECTION *cf_section_alloc(const char *name1, const char *name2,
                                return NULL;
                        }
                }
-               name2_len = strlen(name2) + 1;
        }
 
-       p = rad_malloc(sizeof(*cs) + name1_len + name2_len);
+       cs = talloc_zero(parent, CONF_SECTION);
+       if (!cs) return NULL;
 
-       cs = (CONF_SECTION *) p;
-       memset(cs, 0, sizeof(*cs));
        cs->item.type = CONF_ITEM_SECTION;
        cs->item.parent = parent;
 
-       p += sizeof(*cs);
-       memcpy(p, name1, name1_len);
-       cs->name1 = p;
+       cs->name1 = talloc_strdup(cs, name1);
+       if (!cs->name1) {
+       error:
+               talloc_free(cs);
+               return NULL;
+       }
 
        if (name2 && *name2) {
-               p += name1_len;
-               memcpy(p, name2, name2_len);
-               cs->name2 = p;
+               cs->name2 = talloc_strdup(cs, name2);
+               if (!cs->name2) goto error;
        }
 
        cs->pair_tree = rbtree_create(pair_cmp, NULL, 0);
-       if (!cs->pair_tree) {
-               cf_section_free(&cs);
-               return NULL;
-       }
+       if (!cs->pair_tree) goto error;
+
+       talloc_set_destructor((void *) cs, cf_section_free);
 
        /*
         *      Don't create a data tree, it may not be needed.
@@ -1012,7 +861,7 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                }
 
                cf_log_info(cs, "\t%s = \"%s\"", name, value ? value : "(null)");
-               *q = value ? strdup(value) : NULL;
+               *q = value ? talloc_strdup(cs, value) : NULL;
                break;
 
                /*
@@ -1047,7 +896,7 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                }
 
                cf_log_info(cs, "\t%s = \"%s\"", name, value);
-               *q = value ? strdup(value) : NULL;
+               *q = value ? talloc_strdup(cs, value) : NULL;
 
                /*
                 *      And now we "stat" the file.
@@ -1999,13 +1848,20 @@ CONF_SECTION *cf_file_read(const char *filename)
        cf_item_add(cs, &(cp->item));
 
        if (cf_file_include(filename, cs) < 0) {
-               cf_section_free(&cs);
+               talloc_free(cs);
                return NULL;
        }
 
        return cs;
 }
 
+
+void cf_file_free(CONF_SECTION *cs)
+{
+       talloc_free(cs);
+}
+
+
 /*
  * Return a CONF_PAIR within a CONF_SECTION.
  */
@@ -2417,24 +2273,26 @@ int cf_item_is_pair(const CONF_ITEM *item)
 static CONF_DATA *cf_data_alloc(CONF_SECTION *parent, const char *name,
                                void *data, void (*data_free)(void *))
 {
-       char *p;
-       size_t name_len;
        CONF_DATA *cd;
 
-       name_len = strlen(name) + 1;
-
-       p = rad_malloc(sizeof(*cd) + name_len);
-       cd = (CONF_DATA *) p;
-       memset(cd, 0, sizeof(*cd));
+       cd = talloc_zero(parent, CONF_DATA);
+       if (!cd) return NULL;
 
        cd->item.type = CONF_ITEM_DATA;
        cd->item.parent = parent;
+       cd->name = talloc_strdup(cd, name);
+       if (!cd) {
+               talloc_free(cd);
+               return NULL;
+       }
+
        cd->data = data;
        cd->free = data_free;
 
-       p += sizeof(*cd);
-       memcpy(p, name, name_len);
-       cd->name = p;
+       if (cd->free) {
+               talloc_set_destructor((void *) cd, cf_data_free);
+       }
+
        return cd;
 }
 
index d75b3fa..48b2b47 100644 (file)
@@ -538,14 +538,6 @@ void fr_connection_pool_delete(fr_connection_pool_t *pool)
        rad_assert(pool->tail == NULL);
        rad_assert(pool->num == 0);
        
-       /*
-        *      In legacy configurations we don't always have a configuration
-        *      section and may initialise the pool struct with defaults
-        */
-       if (pool->cs) {
-               cf_section_parse_free(pool->cs, pool);
-       }
-       
        free(pool->log_prefix);
        free(pool);
 }
index f8024fd..dcd53a6 100644 (file)
@@ -1000,10 +1000,8 @@ static int common_socket_parse(CONF_SECTION *cs, rad_listen_t *this)
                } else {
                        cf_log_err(cf_sectiontoitem(cs),
                                   "Unknown proto name \"%s\"", proto);
-                       free(proto);
                        return -1;
                }
-               free(proto);
 
                /*
                 *      TCP requires a destination IP for sockets.
@@ -1186,10 +1184,8 @@ static int common_socket_parse(CONF_SECTION *cs, rad_listen_t *this)
                        cf_log_err(cf_sectiontoitem(cs),
                                   "Failed to find clients %s {...}",
                                   section_name);
-                       free(section_name);
                        return -1;
                }
-               free(section_name);
        } /* else there was no "clients = " entry. */
 
        if (!client_cs) {
@@ -2669,7 +2665,6 @@ static rad_listen_t *listen_parse(CONF_SECTION *cs, const char *server)
                              &listen_type, "");
        if (rcode < 0) return NULL;
        if (rcode == 1) {
-               free(listen_type);
                cf_log_err(cf_sectiontoitem(cs),
                           "No type specified in listen section");
                return NULL;
@@ -2680,10 +2675,8 @@ static rad_listen_t *listen_parse(CONF_SECTION *cs, const char *server)
                cf_log_err(cf_sectiontoitem(cs),
                           "Invalid type \"%s\" in listen section.",
                           listen_type);
-               free(listen_type);
                return NULL;
        }
-       free(listen_type);
 
        /*
         *      Allow listen sections in the default config to
index bf1ddde..a16a53f 100644 (file)
@@ -806,13 +806,13 @@ int read_mainconfig(int reload)
        if (mainconfig.radlog_dest == RADLOG_NULL) {
                if (cf_section_parse(cs, NULL, serverdest_config) < 0) {
                        fprintf(stderr, "radiusd: Error: Failed to parse log{} section.\n");
-                       cf_section_free(&cs);
+                       cf_file_free(cs);
                        return -1;
                }
                
                if (!radlog_dest) {
                        fprintf(stderr, "radiusd: Error: No log destination specified.\n");
-                       cf_section_free(&cs);
+                       cf_file_free(cs);
                        return -1;
                }
                
@@ -821,7 +821,7 @@ int read_mainconfig(int reload)
                if (mainconfig.radlog_dest == RADLOG_NUM_DEST) {
                        fprintf(stderr, "radiusd: Error: Unknown log_destination %s\n",
                                radlog_dest);
-                       cf_section_free(&cs);
+                       cf_file_free(cs);
                        return -1;
                }
                
@@ -832,14 +832,14 @@ int read_mainconfig(int reload)
                         */
                        if (!syslog_facility) {
                                fprintf(stderr, "radiusd: Error: Syslog chosen but no facility was specified\n");
-                               cf_section_free(&cs);
+                               cf_file_free(cs);
                                return -1;
                        }
                        mainconfig.syslog_facility = fr_str2int(syslog_str2fac, syslog_facility, -1);
                        if (mainconfig.syslog_facility < 0) {
                                fprintf(stderr, "radiusd: Error: Unknown syslog_facility %s\n",
                                        syslog_facility);
-                               cf_section_free(&cs);
+                               cf_file_free(cs);
                                return -1;
                        }
 
@@ -854,7 +854,7 @@ int read_mainconfig(int reload)
                } else if (mainconfig.radlog_dest == RADLOG_FILES) {
                        if (!mainconfig.log_file) {
                                fprintf(stderr, "radiusd: Error: Specified \"files\" as a log destination, but no log filename was given!\n");
-                               cf_section_free(&cs);
+                               cf_file_free(cs);
                                return -1;
                        }
                }
@@ -878,7 +878,7 @@ int read_mainconfig(int reload)
                                            O_WRONLY | O_APPEND | O_CREAT, 0640);
                if (mainconfig.radlog_fd < 0) {
                        fprintf(stderr, "radiusd: Failed to open log file %s: %s\n", mainconfig.log_file, strerror(errno));
-                       cf_section_free(&cs);
+                       cf_file_free(cs);
                        return -1;
                }
        }
@@ -1003,7 +1003,7 @@ int free_mainconfig(void)
         */
        for (cc = cs_cache; cc != NULL; cc = next) {
                next = cc->next;
-               cf_section_free(&cc->cs);
+               cf_file_free(cc->cs);
                free(cc);
        }
 
index 964b6c8..959e187 100644 (file)
@@ -378,7 +378,7 @@ static int module_instance_cmp(const void *one, const void *two)
 }
 
 
-static void module_instance_free_old(CONF_SECTION *cs, module_instance_t *node,
+static void module_instance_free_old(UNUSED CONF_SECTION *cs, module_instance_t *node,
                                     time_t when)
 {
        fr_module_hup_t *mh, **last;
index 0db0a8a..0062715 100644 (file)
@@ -5,4 +5,4 @@ SOURCES         := radclient.c ${top_srcdir}/src/modules/rlm_mschap/smbdes.c \
 TGT_PREREQS    := libfreeradius-radius.a
 
 SRC_CFLAGS     := -I${top_srcdir}/src/modules/rlm_mschap
-TGT_LDLIBS     := $(LIBS)
+TGT_LDLIBS     := $(LIBS) -ltalloc
index 5dbfc64..cbe9291 100644 (file)
@@ -8,5 +8,5 @@ SOURCES         := radmin.c conffile.c log.c util.c
 
 TGT_INSTALLDIR  := ${sbindir}
 TGT_PREREQS    := libfreeradius-radius.a
-TGT_LDLIBS     := $(LIBS) $(LIBREADLINE)
+TGT_LDLIBS     := $(LIBS) $(LIBREADLINE) -ltalloc
 
index 2e463b3..5668f26 100644 (file)
@@ -421,7 +421,6 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
        CONF_PAIR *cp;
        CONF_SECTION *tls;
 
-       free(hs_virtual_server); /* used only for printing during parsing */
        hs_virtual_server = NULL;
 
        name2 = cf_section_name2(cs);
@@ -488,15 +487,10 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
                           "No ipaddr, ipv6addr, or virtual_server defined for home server \"%s\".",
                           name2);
        error:
-               free(home);
-               free(hs_type);
                hs_type = NULL;
-               free(hs_check);
                hs_check = NULL;
-               free(hs_srcipaddr);
                hs_srcipaddr = NULL;
 #ifdef WITH_TCP
-               free(hs_proto);
                hs_proto = NULL;
 #endif
                return 0;
@@ -557,7 +551,6 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
                           hs_type, name2);
                goto error;
        }
-       free(hs_type);
        hs_type = NULL;
 
        if (!hs_check || (strcasecmp(hs_check, "none") == 0)) {
@@ -588,7 +581,6 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
                           hs_check, name2);
                goto error;
        }
-       free(hs_check);
        hs_check = NULL;
 
        if ((home->ping_check != HOME_PING_CHECK_NONE) &&
@@ -609,11 +601,9 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
 #ifdef WITH_TCP
        if (hs_proto) {
                if (strcmp(hs_proto, "udp") == 0) {
-                       free(hs_proto);
                        hs_proto = NULL;
                        
                } else if (strcmp(hs_proto, "tcp") == 0) {
-                       free(hs_proto);
                        hs_proto = NULL;
                        home->proto = IPPROTO_TCP;
                        
@@ -702,7 +692,6 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
                home->src_ipaddr.af = home->ipaddr.af;
        }
 
-       free(hs_srcipaddr);
        hs_srcipaddr = NULL;
 
        if (rbtree_finddata(home_servers_byname, home) != NULL) {
index ff533e3..5275488 100644 (file)
@@ -2249,8 +2249,6 @@ static void tls_server_conf_free(fr_tls_server_conf_t *conf)
 {
        if (!conf) return;
 
-       if (conf->cs) cf_section_parse_free(conf->cs, conf);
-
        if (conf->ctx) SSL_CTX_free(conf->ctx);
 
 #ifdef HAVE_OPENSSL_OCSP_H
index e0fdc37..b0314c7 100644 (file)
@@ -251,8 +251,6 @@ done:
 
 void eaptype_free(EAP_TYPES *i)
 {
-       cf_section_parse_free(i->cs, i->type_data);
-
        if (i->type->detach) (i->type->detach)(i->type_data);
        i->type_data = NULL;
        if (i->handle) lt_dlclose(i->handle);