From 8fabcd2605743ac2b2724a9574fb7ccf752faaaf Mon Sep 17 00:00:00 2001 From: Caleb Ristvedt Date: Fri, 3 May 2024 20:25:08 -0500 Subject: [PATCH] Use aligned copy of room key in handle_process_records. --- src/gnunet_chat_handle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c index e169a18..947f70e 100644 --- a/src/gnunet_chat_handle.c +++ b/src/gnunet_chat_handle.c @@ -1020,9 +1020,13 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, if (!record) return NULL; + /* Get a properly-aligned struct to pass to + GNUNET_CONTAINER_multihashmap_get() */ + struct GNUNET_HashCode key; + GNUNET_memcpy (&key, &(record->key), sizeof(key)); struct GNUNET_CHAT_Context *context = GNUNET_CONTAINER_multihashmap_get( handle->contexts, - &(record->key) + &key ); if (context) @@ -1034,7 +1038,7 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, struct GNUNET_MESSENGER_Room *room = GNUNET_MESSENGER_enter_room( handle->messenger, &(record->door), - &(record->key) + &key ); if (!room) @@ -1046,7 +1050,7 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, handle_send_room_name(handle, room); if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( - handle->contexts, &(record->key), context, + handle->contexts, &key, context, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) { context_destroy(context); -- 2.41.0