aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_operation_store.c
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-11-29 12:43:25 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-11-29 12:43:25 +0100
commitf8beb38c5e813ace4799cef75232f6e5c6b3a67b (patch)
tree25bd832d3a7a0ffbd89ff007056ba3144bdf5abd /src/messenger/gnunet-service-messenger_operation_store.c
parentfdb9fc3b6f1333a05e093ed1a8aee63d6308ced1 (diff)
downloadgnunet-f8beb38c5e813ace4799cef75232f6e5c6b3a67b.tar.gz
gnunet-f8beb38c5e813ace4799cef75232f6e5c6b3a67b.zip
-fix messenger load-, store-operations and uninitialized memory
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/messenger/gnunet-service-messenger_operation_store.c')
-rw-r--r--src/messenger/gnunet-service-messenger_operation_store.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/messenger/gnunet-service-messenger_operation_store.c b/src/messenger/gnunet-service-messenger_operation_store.c
index 4f8419daa..276f0b92b 100644
--- a/src/messenger/gnunet-service-messenger_operation_store.c
+++ b/src/messenger/gnunet-service-messenger_operation_store.c
@@ -65,23 +65,20 @@ callback_scan_for_operations (void *cls,
65{ 65{
66 struct GNUNET_MESSENGER_OperationStore *store = cls; 66 struct GNUNET_MESSENGER_OperationStore *store = cls;
67 67
68 if (GNUNET_YES == GNUNET_DISK_file_test (filename)) 68 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
69 { 69 return GNUNET_OK;
70 char *path;
71
72 GNUNET_asprintf (&path, "%s%c", filename, DIR_SEPARATOR);
73 70
74 struct GNUNET_MESSENGER_Operation *op = load_operation(store, path); 71 if ((strlen(filename) <= 4) || (0 != strcmp(filename + strlen(filename) - 4, ".cfg")))
72 return GNUNET_OK;
75 73
76 if ((op) && (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( 74 struct GNUNET_MESSENGER_Operation *op = load_operation(store, filename);
77 store->operations,
78 &(op->hash), op,
79 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
80 {
81 destroy_operation(op);
82 }
83 75
84 GNUNET_free(path); 76 if ((op) && (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
77 store->operations,
78 &(op->hash), op,
79 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
80 {
81 destroy_operation(op);
85 } 82 }
86 83
87 return GNUNET_OK; 84 return GNUNET_OK;
@@ -93,8 +90,13 @@ load_operation_store (struct GNUNET_MESSENGER_OperationStore *store,
93{ 90{
94 GNUNET_assert ((store) && (directory)); 91 GNUNET_assert ((store) && (directory));
95 92
96 if (GNUNET_OK == GNUNET_DISK_directory_test (directory, GNUNET_YES)) 93 char* load_dir;
97 GNUNET_DISK_directory_scan (directory, callback_scan_for_operations, store); 94 GNUNET_asprintf (&load_dir, "%s%s%c", directory, "operations", DIR_SEPARATOR);
95
96 if (GNUNET_OK == GNUNET_DISK_directory_test (load_dir, GNUNET_YES))
97 GNUNET_DISK_directory_scan (load_dir, callback_scan_for_operations, store);
98
99 GNUNET_free(load_dir);
98} 100}
99 101
100static int 102static int