commit 3ccd1326fe4f77ac66746c84f2ad64a8fbc1ec62
parent 7afc106f57f7583b01c796bd7259f8f9a589a2be
Author: Jacki <jacki@thejackimonster.de>
Date: Mon, 22 Apr 2024 01:22:35 +0200
Fix creating file from disk without key
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/gnunet_chat_file.c b/src/gnunet_chat_file.c
@@ -131,7 +131,7 @@ file_create_from_disk (struct GNUNET_CHAT_Handle *handle,
const struct GNUNET_HashCode *hash,
const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
{
- GNUNET_assert((handle) && (name) && (hash) && (key));
+ GNUNET_assert((handle) && (name) && (hash));
struct GNUNET_CHAT_File* file = GNUNET_new(struct GNUNET_CHAT_File);
@@ -141,6 +141,12 @@ file_create_from_disk (struct GNUNET_CHAT_Handle *handle,
file->handle = handle;
file->name = GNUNET_strndup(name, NAME_MAX);
+ if (!key)
+ {
+ file->key = NULL;
+ goto skip_key;
+ }
+
file->key = GNUNET_new(struct GNUNET_CRYPTO_SymmetricSessionKey);
if (!(file->key))
@@ -151,6 +157,8 @@ file_create_from_disk (struct GNUNET_CHAT_Handle *handle,
GNUNET_memcpy(file->key, key,
sizeof(struct GNUNET_CRYPTO_SymmetricSessionKey));
+
+skip_key:
GNUNET_memcpy(&(file->hash), hash, sizeof(file->hash));
file->meta = GNUNET_FS_meta_data_create();