]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check the type of talloced heap elements
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 28 Mar 2018 15:52:13 +0000 (16:52 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 28 Mar 2018 15:52:13 +0000 (16:52 +0100)
src/include/heap.h
src/lib/io/worker.c
src/lib/util/event.c
src/lib/util/heap.c
src/main/pool.c
src/main/unlang_interpret.c
src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c
src/modules/rlm_radius/rlm_radius_udp.c

index dcaf4ee0f63cd42f3176b04496b805f1c121272e..52d5ccfa5a1a56eb6e4d784880d35fbb381881cc 100644 (file)
@@ -54,7 +54,7 @@ typedef struct fr_heap_t fr_heap_t;
  *     - NULL on error.
  */
 #define fr_heap_talloc_create(_cmp, _talloc_type, _field) \
-       _fr_heap_create(_cmp, #_talloc_type, (size_t)offsetof(_talloc_type), _field))
+       _fr_heap_create(_cmp, #_talloc_type, (size_t)offsetof(_talloc_type, _field))
 
 fr_heap_t      *_fr_heap_create(fr_heap_cmp_t cmp, char const *talloc_type, size_t offset);
 
index 34d3ca6c890071794420259bad62d09769f57bfa..bc4c4d82da760a3a8949ef5a5c069f5174851e64 100644 (file)
@@ -1336,13 +1336,13 @@ nomem:
        WORKER_HEAP_INIT(to_decode, worker_message_cmp, fr_channel_data_t, channel.heap_id);
        WORKER_HEAP_INIT(localized, worker_message_cmp, fr_channel_data_t, channel.heap_id);
 
-       worker->runnable = fr_heap_create(worker_runnable_cmp, REQUEST, runnable_id);
+       worker->runnable = fr_heap_talloc_create(worker_runnable_cmp, REQUEST, runnable_id);
        if (!worker->runnable) {
                fr_strerror_printf("Failed creating runnable heap");
                goto fail;
        }
 
-       worker->time_order = fr_heap_create(worker_time_order_cmp, REQUEST, time_order_id);
+       worker->time_order = fr_heap_talloc_create(worker_time_order_cmp, REQUEST, time_order_id);
        if (!worker->time_order) {
                fr_strerror_printf("Failed creating time_order heap");
                goto fail;
index 7a9408fee312ea0847805c73618c1c9a1d33df5b..473c0d756b992391f924ac95a0f222da793e0415 100644 (file)
@@ -1818,7 +1818,7 @@ fr_event_list_t *fr_event_list_alloc(TALLOC_CTX *ctx, fr_event_status_cb_t statu
        el->kq = -1;    /* So destructor can be used before kqueue() provides us with fd */
        talloc_set_destructor(el, _event_list_free);
 
-       el->times = fr_heap_create(fr_event_timer_cmp, fr_event_timer_t, heap_id);
+       el->times = fr_heap_talloc_create(fr_event_timer_cmp, fr_event_timer_t, heap_id);
        if (!el->times) {
                fr_strerror_printf("Failed allocating event heap");
        error:
index a722bed8de49a578fc3516edfea7b8ed7d0592c7..258be23d80334b8b79f66fb72b248c3bb83d0fad 100644 (file)
@@ -109,6 +109,10 @@ int fr_heap_insert(fr_heap_t *hp, void *data)
 {
        int32_t child = hp->num_elements;
 
+#ifndef TALLOC_GET_TYPE_ABORT_NOOP
+       if (hp->type) (void)_talloc_get_type_abort(data, hp->type, __location__);
+#endif
+
        /*
         *      Heap is full.  Double it's size.
         */
index 60fc2e80fbc42e909e46c129cc1a4468a424afb0..b6899b83e2d67119d5c51fe9114f5659acd11495 100644 (file)
@@ -1000,7 +1000,7 @@ fr_pool_t *fr_pool_init(TALLOC_CTX *ctx,
         *      https://code.facebook.com/posts/1499322996995183/solving-the-mystery-of-link-imbalance-a-metastable-failure-state-at-scale/
         */
        if (!pool->spread) {
-               pool->heap = fr_heap_create(last_reserved_cmp, fr_pool_connection_t, heap_id);
+               pool->heap = fr_heap_talloc_create(last_reserved_cmp, fr_pool_connection_t, heap_id);
        /*
         *      For some types of connections we need to used a different
         *      algorithm, because load balancing benefits are secondary
@@ -1020,7 +1020,7 @@ fr_pool_t *fr_pool_init(TALLOC_CTX *ctx,
         *      That way we maximise time between connection use.
         */
        } else {
-               pool->heap = fr_heap_create(last_released_cmp, fr_pool_connection_t, heap_id);
+               pool->heap = fr_heap_talloc_create(last_released_cmp, fr_pool_connection_t, heap_id);
        }
        if (!pool->heap) {
                ERROR("%s: Failed creating connection heap", __FUNCTION__);
index 415aa24f9d36c998b5b112bfd0fe98cd8b21d840..c51a9dd180893a39739f582b7790f12f353adef3 100644 (file)
@@ -773,7 +773,7 @@ rlm_rcode_t unlang_interpret_synchronous(REQUEST *request, CONF_SECTION *cs, rlm
                return RLM_MODULE_FAIL;
        }
 
-       MEM(backlog = fr_heap_create(_unlang_request_ptr_cmp, REQUEST, runnable_id));
+       MEM(backlog = fr_heap_talloc_create(_unlang_request_ptr_cmp, REQUEST, runnable_id));
        old_el = request->el;
        old_backlog = request->backlog;
        caller = request->module;
index cd9a5a1cc08d49b9e2a68b82ba6c83d200b56b84..7d6e39c5226ca5d1e4af8aa13bc00eea946b132c 100644 (file)
@@ -118,7 +118,7 @@ static int mod_instantiate(UNUSED rlm_cache_config_t const *config, void *instan
        /*
         *      The heap of entries to expire.
         */
-       driver->heap = fr_heap_create(cache_heap_cmp, rlm_cache_rbtree_entry_t, heap_id);
+       driver->heap = fr_heap_talloc_create(cache_heap_cmp, rlm_cache_rbtree_entry_t, heap_id);
        if (!driver->heap) {
                ERROR("Failed to create heap for the cache");
                return -1;
index 58e0612e397b0910c9a579716d502d1849404364..9b8c72619006a1034eb6bb45880e1dc6348cc53b 100644 (file)
@@ -2594,13 +2594,13 @@ static int mod_thread_instantiate(UNUSED CONF_SECTION const *cs, void *instance,
        t->inst = instance;
        t->el = el;
 
-       t->queued = fr_heap_create(queue_cmp, rlm_radius_udp_request_t, heap_id);
+       t->queued = fr_heap_talloc_create(queue_cmp, rlm_radius_udp_request_t, heap_id);
        FR_DLIST_INIT(t->blocked);
        FR_DLIST_INIT(t->full);
        FR_DLIST_INIT(t->zombie);
        FR_DLIST_INIT(t->opening);
 
-       t->active = fr_heap_create(conn_cmp, rlm_radius_udp_connection_t, heap_id);
+       t->active = fr_heap_talloc_create(conn_cmp, rlm_radius_udp_connection_t, heap_id);
 
        conn_alloc(t->inst, t);