diff options
Diffstat (limited to 'src/messenger/plugin_gnsrecord_messenger.c')
-rw-r--r-- | src/messenger/plugin_gnsrecord_messenger.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/messenger/plugin_gnsrecord_messenger.c b/src/messenger/plugin_gnsrecord_messenger.c index e09a0330d..ed675dd1d 100644 --- a/src/messenger/plugin_gnsrecord_messenger.c +++ b/src/messenger/plugin_gnsrecord_messenger.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -59,8 +59,11 @@ messenger_value_to_string (void *cls, | |||
59 | 59 | ||
60 | const struct GNUNET_MESSENGER_RoomEntryRecord *record = data; | 60 | const struct GNUNET_MESSENGER_RoomEntryRecord *record = data; |
61 | 61 | ||
62 | char *door = GNUNET_CRYPTO_eddsa_public_key_to_string (&(record->door.public_key)); | 62 | char *door = GNUNET_CRYPTO_eddsa_public_key_to_string ( |
63 | char *key = GNUNET_STRINGS_data_to_string_alloc (&(record->key), sizeof(struct GNUNET_HashCode)); | 63 | &(record->door.public_key)); |
64 | char *key = GNUNET_STRINGS_data_to_string_alloc (&(record->key), | ||
65 | sizeof(struct | ||
66 | GNUNET_HashCode)); | ||
64 | 67 | ||
65 | char *ret; | 68 | char *ret; |
66 | GNUNET_asprintf (&ret, "%s-%s", key, door); | 69 | GNUNET_asprintf (&ret, "%s-%s", key, door); |
@@ -78,8 +81,9 @@ messenger_value_to_string (void *cls, | |||
78 | 81 | ||
79 | const struct GNUNET_MESSENGER_RoomDetailsRecord *record = data; | 82 | const struct GNUNET_MESSENGER_RoomDetailsRecord *record = data; |
80 | 83 | ||
81 | char *name = GNUNET_strndup(record->name, 256); | 84 | char *name = GNUNET_strndup (record->name, 256); |
82 | char *flags = GNUNET_STRINGS_data_to_string_alloc (&(record->flags), sizeof(uint32_t)); | 85 | char *flags = GNUNET_STRINGS_data_to_string_alloc (&(record->flags), |
86 | sizeof(uint32_t)); | ||
83 | 87 | ||
84 | char *ret; | 88 | char *ret; |
85 | GNUNET_asprintf (&ret, "%s-%s", flags, name); | 89 | GNUNET_asprintf (&ret, "%s-%s", flags, name); |
@@ -122,15 +126,17 @@ messenger_string_to_value (void *cls, | |||
122 | { | 126 | { |
123 | case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY: | 127 | case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY: |
124 | { | 128 | { |
125 | char key [103]; | 129 | char key[103]; |
126 | const char *dash; | 130 | const char *dash; |
127 | struct GNUNET_PeerIdentity door; | 131 | struct GNUNET_PeerIdentity door; |
128 | 132 | ||
129 | if ((NULL == (dash = strchr (s, '-'))) || | 133 | if ((NULL == (dash = strchr (s, '-'))) || |
130 | (1 != sscanf (s, "%103s-", key)) || | 134 | (1 != sscanf (s, "%103s-", key)) || |
131 | (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (dash + 1, | 135 | (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (dash + 1, |
132 | strlen (dash + 1), | 136 | strlen ( |
133 | &(door.public_key)))) | 137 | dash + 1), |
138 | &(door. | ||
139 | public_key)))) | ||
134 | { | 140 | { |
135 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 141 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
136 | _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"), | 142 | _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"), |
@@ -139,13 +145,14 @@ messenger_string_to_value (void *cls, | |||
139 | } | 145 | } |
140 | 146 | ||
141 | struct GNUNET_MESSENGER_RoomEntryRecord *record = GNUNET_new ( | 147 | struct GNUNET_MESSENGER_RoomEntryRecord *record = GNUNET_new ( |
142 | struct GNUNET_MESSENGER_RoomEntryRecord | 148 | struct GNUNET_MESSENGER_RoomEntryRecord |
143 | ); | 149 | ); |
144 | 150 | ||
145 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (key, | 151 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (key, |
146 | strlen (key), | 152 | strlen (key), |
147 | &(record->key), | 153 | &(record->key), |
148 | sizeof(struct GNUNET_HashCode))) | 154 | sizeof(struct |
155 | GNUNET_HashCode))) | ||
149 | { | 156 | { |
150 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 157 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
151 | _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"), | 158 | _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"), |
@@ -161,7 +168,7 @@ messenger_string_to_value (void *cls, | |||
161 | } | 168 | } |
162 | case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS: | 169 | case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS: |
163 | { | 170 | { |
164 | char flags [7]; | 171 | char flags[7]; |
165 | const char *dash; | 172 | const char *dash; |
166 | 173 | ||
167 | if ((NULL == (dash = strchr (s, '-'))) || | 174 | if ((NULL == (dash = strchr (s, '-'))) || |
@@ -175,8 +182,8 @@ messenger_string_to_value (void *cls, | |||
175 | } | 182 | } |
176 | 183 | ||
177 | struct GNUNET_MESSENGER_RoomDetailsRecord *record = GNUNET_new ( | 184 | struct GNUNET_MESSENGER_RoomDetailsRecord *record = GNUNET_new ( |
178 | struct GNUNET_MESSENGER_RoomDetailsRecord | 185 | struct GNUNET_MESSENGER_RoomDetailsRecord |
179 | ); | 186 | ); |
180 | 187 | ||
181 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (flags, | 188 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (flags, |
182 | strlen (flags), | 189 | strlen (flags), |
@@ -190,7 +197,7 @@ messenger_string_to_value (void *cls, | |||
190 | return GNUNET_SYSERR; | 197 | return GNUNET_SYSERR; |
191 | } | 198 | } |
192 | 199 | ||
193 | GNUNET_memcpy(record->name, dash + 1, strlen(dash + 1)); | 200 | GNUNET_memcpy (record->name, dash + 1, strlen (dash + 1)); |
194 | 201 | ||
195 | *data = record; | 202 | *data = record; |
196 | *data_size = sizeof(struct GNUNET_MESSENGER_RoomDetailsRecord); | 203 | *data_size = sizeof(struct GNUNET_MESSENGER_RoomDetailsRecord); |