commit e7fb68155e1333c7af024ebec8f270b111dadf1c
parent ec034cc870363915794b599dcd91dd4648f0a588
Author: Jacki <jacki@thejackimonster.de>
Date: Tue, 23 Jun 2026 02:54:43 +0200
Fix issue when FS is calculating hash of file sent differently than libgnunetchat
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/src/gnunet_chat_file.c b/src/gnunet_chat_file.c
@@ -63,19 +63,6 @@ file_create_from_message (struct GNUNET_CHAT_Handle *handle,
{
GNUNET_assert((handle) && (message) && (message->uri));
- struct GNUNET_FS_Uri *uri = GNUNET_FS_uri_parse(message->uri, NULL);
-
- if (!uri)
- return NULL;
-
- const struct GNUNET_HashCode *hash = GNUNET_FS_uri_chk_get_file_hash(uri);
-
- if ((!hash) || (0 != GNUNET_CRYPTO_hash_cmp(hash, &(message->hash))))
- {
- GNUNET_FS_uri_destroy(uri);
- return NULL;
- }
-
struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File);
if (!file)
@@ -84,10 +71,10 @@ file_create_from_message (struct GNUNET_CHAT_Handle *handle,
file->handle = handle;
file->name = GNUNET_strndup(message->name, NAME_MAX);
- memcpy(&(file->hash), hash, sizeof(file->hash));
+ memcpy(&(file->hash), &(message->hash), sizeof(file->hash));
file->meta = GNUNET_FS_meta_data_create();
- file->uri = uri;
+ file->uri = GNUNET_FS_uri_parse(message->uri, NULL);
file_initialize(file);
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
@@ -873,6 +873,9 @@ on_handle_message_callback(void *cls)
context->handle, &(message->msg->body.file)
);
+ if (!file)
+ break;
+
if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
context->handle->files, &(file->hash), file,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))