Skip to content

Commit

Permalink
Use talloc get type abort for safety...
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed May 14, 2024
1 parent 3d93a31 commit 8a4c3cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/lib/io/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,14 +1292,14 @@ static int _network_socket_free(fr_network_socket_t *s)
*/
static void fr_network_listen_callback(void *ctx, void const *data, size_t data_size, UNUSED fr_time_t now)
{
fr_network_t *nr = ctx;
fr_network_t *nr = talloc_get_type_abort(ctx, fr_network_t);
fr_listen_t *li;

fr_assert(data_size == sizeof(li));

if (data_size != sizeof(li)) return;

memcpy(&li, data, sizeof(li));
li = talloc_get_type_abort(*((void * const *)data), fr_listen_t);

(void) fr_network_listen_add_self(nr, li);
}
Expand Down Expand Up @@ -1420,8 +1420,8 @@ static int fr_network_listen_add_self(fr_network_t *nr, fr_listen_t *li)
static void fr_network_directory_callback(void *ctx, void const *data, size_t data_size, UNUSED fr_time_t now)
{
int num_messages;
fr_network_t *nr = ctx;
fr_listen_t *li;
fr_network_t *nr = talloc_get_type_abort(ctx, fr_network_t);
fr_listen_t *li = talloc_get_type_abort(*((void * const *)data), fr_listen_t);
fr_network_socket_t *s;
fr_app_io_t const *app_io;
fr_event_vnode_func_t funcs = { .extend = fr_network_vnode_extend };
Expand Down
2 changes: 1 addition & 1 deletion src/listen/detail/proto_detail_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int mod_decode(void const *instance, request_t *request, UNUSED uint8_t *
{

proto_detail_work_t const *inst = talloc_get_type_abort_const(instance, proto_detail_work_t);
fr_detail_entry_t const *track = request->async->packet_ctx;
fr_detail_entry_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_detail_entry_t);
fr_pair_t *vp;

request->client = inst->client;
Expand Down

0 comments on commit 8a4c3cd

Please sign in to comment.