diff options
-rw-r--r-- | src/include/gnunet_messenger_service.h | 4 | ||||
-rw-r--r-- | src/json/json.c | 7 | ||||
-rw-r--r-- | src/json/json_generator.c | 10 | ||||
-rw-r--r-- | src/json/json_helper.c | 11 | ||||
-rw-r--r-- | src/messenger/gnunet-service-messenger_message_handle.c | 4 | ||||
-rw-r--r-- | src/messenger/gnunet-service-messenger_message_kind.c | 4 | ||||
-rw-r--r-- | src/messenger/messenger_api_message.c | 46 | ||||
-rw-r--r-- | src/messenger/messenger_api_room.c | 4 | ||||
-rw-r--r-- | src/testbed/gnunet-cmds-helper.c | 12 | ||||
-rw-r--r-- | src/util/configuration.c | 64 | ||||
-rw-r--r-- | src/util/gnunet-base32.c | 14 |
11 files changed, 116 insertions, 64 deletions
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index 81bc3aa12..ecd856eb9 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -476,8 +476,8 @@ struct GNUNET_MESSENGER_MessageBody | |||
476 | struct GNUNET_MESSENGER_MessageInvite invite; | 476 | struct GNUNET_MESSENGER_MessageInvite invite; |
477 | struct GNUNET_MESSENGER_MessageText text; | 477 | struct GNUNET_MESSENGER_MessageText text; |
478 | struct GNUNET_MESSENGER_MessageFile file; | 478 | struct GNUNET_MESSENGER_MessageFile file; |
479 | struct GNUNET_MESSENGER_MessagePrivate private; | 479 | struct GNUNET_MESSENGER_MessagePrivate privacy; |
480 | struct GNUNET_MESSENGER_MessageDelete delete; | 480 | struct GNUNET_MESSENGER_MessageDelete deletion; |
481 | }; | 481 | }; |
482 | }; | 482 | }; |
483 | 483 | ||
diff --git a/src/json/json.c b/src/json/json.c index 503702962..d55189804 100644 --- a/src/json/json.c +++ b/src/json/json.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2014-2017 GNUnet e.V. | 3 | Copyright (C) 2014-2017, 2021 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 |
@@ -70,6 +70,11 @@ GNUNET_JSON_parse (const json_t *root, | |||
70 | { | 70 | { |
71 | if (NULL != error_json_name) | 71 | if (NULL != error_json_name) |
72 | *error_json_name = spec[i].field; | 72 | *error_json_name = spec[i].field; |
73 | else | ||
74 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
75 | "Parsing failed for field `%s:%u`\n", | ||
76 | spec[i].field, | ||
77 | i); | ||
73 | if (NULL != error_line) | 78 | if (NULL != error_line) |
74 | *error_line = i; | 79 | *error_line = i; |
75 | GNUNET_JSON_parse_free (spec); | 80 | GNUNET_JSON_parse_free (spec); |
diff --git a/src/json/json_generator.c b/src/json/json_generator.c index 5806eb174..0c513ca9d 100644 --- a/src/json/json_generator.c +++ b/src/json/json_generator.c | |||
@@ -42,7 +42,14 @@ GNUNET_JSON_from_data (const void *data, | |||
42 | char *buf; | 42 | char *buf; |
43 | json_t *json; | 43 | json_t *json; |
44 | 44 | ||
45 | buf = GNUNET_STRINGS_data_to_string_alloc (data, size); | 45 | if ((size * 8 + 4) / 5 + 1 >= |
46 | GNUNET_MAX_MALLOC_CHECKED) | ||
47 | { | ||
48 | GNUNET_break (0); | ||
49 | return NULL; | ||
50 | } | ||
51 | buf = GNUNET_STRINGS_data_to_string_alloc (data, | ||
52 | size); | ||
46 | json = json_string (buf); | 53 | json = json_string (buf); |
47 | GNUNET_free (buf); | 54 | GNUNET_free (buf); |
48 | GNUNET_break (NULL != json); | 55 | GNUNET_break (NULL != json); |
@@ -201,5 +208,4 @@ GNUNET_JSON_from_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *sig) | |||
201 | } | 208 | } |
202 | 209 | ||
203 | 210 | ||
204 | |||
205 | /* End of json/json_generator.c */ | 211 | /* End of json/json_generator.c */ |
diff --git a/src/json/json_helper.c b/src/json/json_helper.c index 6189b7596..03db9ec80 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c | |||
@@ -125,7 +125,7 @@ parse_variable_data (void *cls, | |||
125 | return GNUNET_SYSERR; | 125 | return GNUNET_SYSERR; |
126 | } | 126 | } |
127 | size = (strlen (str) * 5) / 8; | 127 | size = (strlen (str) * 5) / 8; |
128 | if (size >= 1024) | 128 | if (size >= GNUNET_MAX_MALLOC_CHECKED) |
129 | { | 129 | { |
130 | GNUNET_break_op (0); | 130 | GNUNET_break_op (0); |
131 | return GNUNET_SYSERR; | 131 | return GNUNET_SYSERR; |
@@ -135,6 +135,15 @@ parse_variable_data (void *cls, | |||
135 | strlen (str), | 135 | strlen (str), |
136 | data, | 136 | data, |
137 | size); | 137 | size); |
138 | if ( (0 < size) && | ||
139 | (GNUNET_OK != res) ) | ||
140 | { | ||
141 | size--; | ||
142 | res = GNUNET_STRINGS_string_to_data (str, | ||
143 | strlen (str), | ||
144 | data, | ||
145 | size); | ||
146 | } | ||
138 | if (GNUNET_OK != res) | 147 | if (GNUNET_OK != res) |
139 | { | 148 | { |
140 | GNUNET_break_op (0); | 149 | GNUNET_break_op (0); |
diff --git a/src/messenger/gnunet-service-messenger_message_handle.c b/src/messenger/gnunet-service-messenger_message_handle.c index 1d489310c..86f2b901a 100644 --- a/src/messenger/gnunet-service-messenger_message_handle.c +++ b/src/messenger/gnunet-service-messenger_message_handle.c | |||
@@ -126,11 +126,11 @@ void | |||
126 | handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | 126 | handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, |
127 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 127 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
128 | { | 128 | { |
129 | struct GNUNET_TIME_Relative delay = GNUNET_TIME_relative_ntoh (message->body.delete.delay); | 129 | struct GNUNET_TIME_Relative delay = GNUNET_TIME_relative_ntoh (message->body.deletion.delay); |
130 | struct GNUNET_TIME_Absolute action = GNUNET_TIME_absolute_ntoh (message->header.timestamp); | 130 | struct GNUNET_TIME_Absolute action = GNUNET_TIME_absolute_ntoh (message->header.timestamp); |
131 | 131 | ||
132 | action = GNUNET_TIME_absolute_add (action, delay); | 132 | action = GNUNET_TIME_absolute_add (action, delay); |
133 | delay = GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get (), action); | 133 | delay = GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get (), action); |
134 | 134 | ||
135 | delete_room_message (room, session, &(message->body.delete.hash), delay); | 135 | delete_room_message (room, session, &(message->body.deletion.hash), delay); |
136 | } | 136 | } |
diff --git a/src/messenger/gnunet-service-messenger_message_kind.c b/src/messenger/gnunet-service-messenger_message_kind.c index ef9bbfd2e..3edcade91 100644 --- a/src/messenger/gnunet-service-messenger_message_kind.c +++ b/src/messenger/gnunet-service-messenger_message_kind.c | |||
@@ -232,8 +232,8 @@ create_message_delete (const struct GNUNET_HashCode *hash, const struct GNUNET_T | |||
232 | if (!message) | 232 | if (!message) |
233 | return NULL; | 233 | return NULL; |
234 | 234 | ||
235 | GNUNET_memcpy(&(message->body.delete.hash), hash, sizeof(struct GNUNET_HashCode)); | 235 | GNUNET_memcpy(&(message->body.deletion.hash), hash, sizeof(struct GNUNET_HashCode)); |
236 | message->body.delete.delay = GNUNET_TIME_relative_hton (delay); | 236 | message->body.deletion.delay = GNUNET_TIME_relative_hton (delay); |
237 | 237 | ||
238 | return message; | 238 | return message; |
239 | } | 239 | } |
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c index facd7b093..c7364d51c 100644 --- a/src/messenger/messenger_api_message.c +++ b/src/messenger/messenger_api_message.c | |||
@@ -56,8 +56,8 @@ create_message (enum GNUNET_MESSENGER_MessageKind kind) | |||
56 | message->body.file.uri = NULL; | 56 | message->body.file.uri = NULL; |
57 | break; | 57 | break; |
58 | case GNUNET_MESSENGER_KIND_PRIVATE: | 58 | case GNUNET_MESSENGER_KIND_PRIVATE: |
59 | message->body.private.length = 0; | 59 | message->body.privacy.length = 0; |
60 | message->body.private.data = NULL; | 60 | message->body.privacy.data = NULL; |
61 | break; | 61 | break; |
62 | default: | 62 | default: |
63 | break; | 63 | break; |
@@ -87,11 +87,11 @@ copy_message (const struct GNUNET_MESSENGER_Message *message) | |||
87 | copy->body.file.uri = GNUNET_strdup(message->body.file.uri); | 87 | copy->body.file.uri = GNUNET_strdup(message->body.file.uri); |
88 | break; | 88 | break; |
89 | case GNUNET_MESSENGER_KIND_PRIVATE: | 89 | case GNUNET_MESSENGER_KIND_PRIVATE: |
90 | copy->body.private.data = copy->body.private.length ? GNUNET_malloc(copy->body.private.length) : NULL; | 90 | copy->body.privacy.data = copy->body.privacy.length ? GNUNET_malloc(copy->body.privacy.length) : NULL; |
91 | 91 | ||
92 | if (copy->body.private.data) | 92 | if (copy->body.privacy.data) |
93 | { | 93 | { |
94 | GNUNET_memcpy(copy->body.private.data, message->body.private.data, copy->body.private.length); | 94 | GNUNET_memcpy(copy->body.privacy.data, message->body.privacy.data, copy->body.privacy.length); |
95 | } | 95 | } |
96 | 96 | ||
97 | break; | 97 | break; |
@@ -117,7 +117,7 @@ destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESS | |||
117 | GNUNET_free(body->file.uri); | 117 | GNUNET_free(body->file.uri); |
118 | break; | 118 | break; |
119 | case GNUNET_MESSENGER_KIND_PRIVATE: | 119 | case GNUNET_MESSENGER_KIND_PRIVATE: |
120 | GNUNET_free(body->private.data); | 120 | GNUNET_free(body->privacy.data); |
121 | break; | 121 | break; |
122 | default: | 122 | default: |
123 | break; | 123 | break; |
@@ -206,7 +206,7 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind) | |||
206 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.name); | 206 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.name); |
207 | break; | 207 | break; |
208 | case GNUNET_MESSENGER_KIND_PRIVATE: | 208 | case GNUNET_MESSENGER_KIND_PRIVATE: |
209 | length += member_size(struct GNUNET_MESSENGER_Message, body.private.key); | 209 | length += member_size(struct GNUNET_MESSENGER_Message, body.privacy.key); |
210 | break; | 210 | break; |
211 | default: | 211 | default: |
212 | break; | 212 | break; |
@@ -256,7 +256,7 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUN | |||
256 | length += strlen (body->file.uri); | 256 | length += strlen (body->file.uri); |
257 | break; | 257 | break; |
258 | case GNUNET_MESSENGER_KIND_PRIVATE: | 258 | case GNUNET_MESSENGER_KIND_PRIVATE: |
259 | length += body->private.length; | 259 | length += body->privacy.length; |
260 | break; | 260 | break; |
261 | default: | 261 | default: |
262 | break; | 262 | break; |
@@ -421,8 +421,8 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET | |||
421 | encode_step_ext(buffer, offset, body->file.uri, min(length - offset, strlen(body->file.uri))); | 421 | encode_step_ext(buffer, offset, body->file.uri, min(length - offset, strlen(body->file.uri))); |
422 | break; | 422 | break; |
423 | case GNUNET_MESSENGER_KIND_PRIVATE: | 423 | case GNUNET_MESSENGER_KIND_PRIVATE: |
424 | encode_step(buffer, offset, &(body->private.key)); | 424 | encode_step(buffer, offset, &(body->privacy.key)); |
425 | encode_step_ext(buffer, offset, body->private.data, min(length - offset, body->private.length)); | 425 | encode_step_ext(buffer, offset, body->privacy.data, min(length - offset, body->privacy.length)); |
426 | break; | 426 | break; |
427 | default: | 427 | default: |
428 | break; | 428 | break; |
@@ -579,10 +579,10 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESS | |||
579 | decode_step_malloc(buffer, offset, body->file.uri, length - offset, 1); | 579 | decode_step_malloc(buffer, offset, body->file.uri, length - offset, 1); |
580 | break; | 580 | break; |
581 | case GNUNET_MESSENGER_KIND_PRIVATE: | 581 | case GNUNET_MESSENGER_KIND_PRIVATE: |
582 | decode_step(buffer, offset, &(body->private.key)); | 582 | decode_step(buffer, offset, &(body->privacy.key)); |
583 | 583 | ||
584 | body->private.length = (length - offset); | 584 | body->privacy.length = (length - offset); |
585 | decode_step_malloc(buffer, offset, body->private.data, length - offset, 0); | 585 | decode_step_malloc(buffer, offset, body->privacy.data, length - offset, 0); |
586 | break; | 586 | break; |
587 | default: | 587 | default: |
588 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; | 588 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; |
@@ -738,14 +738,14 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I | |||
738 | const uint16_t padded_length = calc_padded_length(length); | 738 | const uint16_t padded_length = calc_padded_length(length); |
739 | 739 | ||
740 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; | 740 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; |
741 | message->body.private.data = GNUNET_malloc(padded_length); | 741 | message->body.privacy.data = GNUNET_malloc(padded_length); |
742 | message->body.private.length = padded_length; | 742 | message->body.privacy.length = padded_length; |
743 | 743 | ||
744 | encode_short_message (&shortened, padded_length, message->body.private.data); | 744 | encode_short_message (&shortened, padded_length, message->body.privacy.data); |
745 | 745 | ||
746 | if (padded_length == GNUNET_IDENTITY_encrypt (message->body.private.data, padded_length, key, | 746 | if (padded_length == GNUNET_IDENTITY_encrypt (message->body.privacy.data, padded_length, key, |
747 | &(message->body.private.key), | 747 | &(message->body.privacy.key), |
748 | message->body.private.data)) | 748 | message->body.privacy.data)) |
749 | { | 749 | { |
750 | destroy_message_body (shortened.kind, &(shortened.body)); | 750 | destroy_message_body (shortened.kind, &(shortened.body)); |
751 | return GNUNET_YES; | 751 | return GNUNET_YES; |
@@ -764,9 +764,9 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I | |||
764 | { | 764 | { |
765 | GNUNET_assert((message) && (key)); | 765 | GNUNET_assert((message) && (key)); |
766 | 766 | ||
767 | if (message->body.private.length != GNUNET_IDENTITY_decrypt (message->body.private.data, message->body.private.length, | 767 | if (message->body.privacy.length != GNUNET_IDENTITY_decrypt (message->body.privacy.data, message->body.privacy.length, |
768 | key, &(message->body.private.key), | 768 | key, &(message->body.privacy.key), |
769 | message->body.private.data)) | 769 | message->body.privacy.data)) |
770 | { | 770 | { |
771 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decrypting message failed!\n"); | 771 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decrypting message failed!\n"); |
772 | 772 | ||
@@ -775,7 +775,7 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I | |||
775 | 775 | ||
776 | struct GNUNET_MESSENGER_ShortMessage shortened; | 776 | struct GNUNET_MESSENGER_ShortMessage shortened; |
777 | 777 | ||
778 | if (GNUNET_YES != decode_short_message (&shortened, message->body.private.length, message->body.private.data)) | 778 | if (GNUNET_YES != decode_short_message (&shortened, message->body.privacy.length, message->body.privacy.data)) |
779 | { | 779 | { |
780 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decoding decrypted message failed!\n"); | 780 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Decoding decrypted message failed!\n"); |
781 | 781 | ||
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c index 67a6015ab..0d9237a2e 100644 --- a/src/messenger/messenger_api_room.c +++ b/src/messenger/messenger_api_room.c | |||
@@ -205,11 +205,11 @@ handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENG | |||
205 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 205 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
206 | { | 206 | { |
207 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_CONTAINER_multihashmap_get ( | 207 | struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_CONTAINER_multihashmap_get ( |
208 | room->messages, &(message->body.delete.hash) | 208 | room->messages, &(message->body.deletion.hash) |
209 | ); | 209 | ); |
210 | 210 | ||
211 | if ((entry) && ((entry->sender == sender) || (get_handle_contact (room->handle, &(room->key)) == sender)) && | 211 | if ((entry) && ((entry->sender == sender) || (get_handle_contact (room->handle, &(room->key)) == sender)) && |
212 | (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (room->messages, &(message->body.delete.hash), entry))) | 212 | (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (room->messages, &(message->body.deletion.hash), entry))) |
213 | { | 213 | { |
214 | destroy_message (entry->message); | 214 | destroy_message (entry->message); |
215 | GNUNET_free(entry); | 215 | GNUNET_free(entry); |
diff --git a/src/testbed/gnunet-cmds-helper.c b/src/testbed/gnunet-cmds-helper.c index 6498d1279..41d6c06b8 100644 --- a/src/testbed/gnunet-cmds-helper.c +++ b/src/testbed/gnunet-cmds-helper.c | |||
@@ -283,8 +283,6 @@ shutdown_task (void *cls) | |||
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | |||
287 | |||
288 | /** | 286 | /** |
289 | * Task to write to the standard out | 287 | * Task to write to the standard out |
290 | * | 288 | * |
@@ -551,10 +549,10 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
551 | } | 549 | } |
552 | 550 | ||
553 | 551 | ||
554 | error: | 552 | error: |
555 | status = GNUNET_SYSERR; | 553 | status = GNUNET_SYSERR; |
556 | LOG (GNUNET_ERROR_TYPE_ERROR, | 554 | LOG (GNUNET_ERROR_TYPE_ERROR, |
557 | "tokenizer shuting down!\n"); | 555 | "tokenizer shutting down!\n"); |
558 | GNUNET_SCHEDULER_shutdown (); | 556 | GNUNET_SCHEDULER_shutdown (); |
559 | return GNUNET_SYSERR; | 557 | return GNUNET_SYSERR; |
560 | } | 558 | } |
@@ -577,7 +575,7 @@ read_task (void *cls) | |||
577 | { | 575 | { |
578 | LOG_DEBUG ("STDIN closed\n"); | 576 | LOG_DEBUG ("STDIN closed\n"); |
579 | LOG (GNUNET_ERROR_TYPE_ERROR, | 577 | LOG (GNUNET_ERROR_TYPE_ERROR, |
580 | "tokenizer shuting down during reading!\n"); | 578 | "tokenizer shutting down during reading!\n"); |
581 | GNUNET_SCHEDULER_shutdown (); | 579 | GNUNET_SCHEDULER_shutdown (); |
582 | return; | 580 | return; |
583 | } | 581 | } |
@@ -586,7 +584,7 @@ read_task (void *cls) | |||
586 | /* didn't expect any more data! */ | 584 | /* didn't expect any more data! */ |
587 | GNUNET_break_op (0); | 585 | GNUNET_break_op (0); |
588 | LOG (GNUNET_ERROR_TYPE_ERROR, | 586 | LOG (GNUNET_ERROR_TYPE_ERROR, |
589 | "tokenizer shuting down during reading, didn't expect any more data!\n"); | 587 | "tokenizer shutting down during reading, didn't expect any more data!\n"); |
590 | GNUNET_SCHEDULER_shutdown (); | 588 | GNUNET_SCHEDULER_shutdown (); |
591 | return; | 589 | return; |
592 | } | 590 | } |
@@ -600,7 +598,7 @@ read_task (void *cls) | |||
600 | { | 598 | { |
601 | GNUNET_break (0); | 599 | GNUNET_break (0); |
602 | LOG (GNUNET_ERROR_TYPE_ERROR, | 600 | LOG (GNUNET_ERROR_TYPE_ERROR, |
603 | "tokenizer shuting down during reading, writing to buffer failed!\n"); | 601 | "tokenizer shutting down during reading, writing to buffer failed!\n"); |
604 | GNUNET_SCHEDULER_shutdown (); | 602 | GNUNET_SCHEDULER_shutdown (); |
605 | return; | 603 | return; |
606 | } | 604 | } |
diff --git a/src/util/configuration.c b/src/util/configuration.c index 3294d11f4..d0090ae53 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2006, 2007, 2008, 2009, 2013, 2020 GNUnet e.V. | 3 | Copyright (C) 2006, 2007, 2008, 2009, 2013, 2020, 2021 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 |
@@ -260,13 +260,14 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
260 | pos = memchr (&mem[r_bytes], '\n', to_read); | 260 | pos = memchr (&mem[r_bytes], '\n', to_read); |
261 | if (NULL == pos) | 261 | if (NULL == pos) |
262 | { | 262 | { |
263 | line_orig = GNUNET_strndup (&mem[r_bytes], line_size = to_read); | 263 | line_orig = GNUNET_strndup (&mem[r_bytes], |
264 | line_size = to_read); | ||
264 | r_bytes += line_size; | 265 | r_bytes += line_size; |
265 | } | 266 | } |
266 | else | 267 | else |
267 | { | 268 | { |
268 | line_orig = | 269 | line_orig = GNUNET_strndup (&mem[r_bytes], |
269 | GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes])); | 270 | line_size = (pos - &mem[r_bytes])); |
270 | r_bytes += line_size + 1; | 271 | r_bytes += line_size + 1; |
271 | } | 272 | } |
272 | line = line_orig; | 273 | line = line_orig; |
@@ -288,7 +289,8 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
288 | continue; | 289 | continue; |
289 | 290 | ||
290 | /* remove tailing whitespace */ | 291 | /* remove tailing whitespace */ |
291 | for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i])); | 292 | for (i = line_size - 1; |
293 | (i >= 1) && (isspace ((unsigned char) line[i])); | ||
292 | i--) | 294 | i--) |
293 | line[i] = '\0'; | 295 | line[i] = '\0'; |
294 | 296 | ||
@@ -297,26 +299,46 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
297 | ; | 299 | ; |
298 | 300 | ||
299 | /* ignore comments */ | 301 | /* ignore comments */ |
300 | if (('#' == line[0]) || ('%' == line[0])) | 302 | if ( ('#' == line[0]) || |
303 | ('%' == line[0]) ) | ||
301 | continue; | 304 | continue; |
302 | 305 | ||
303 | /* handle special "@INLINE@" directive */ | 306 | /* handle special "@INLINE@" directive */ |
304 | if (0 == strncasecmp (line, "@INLINE@ ", strlen ("@INLINE@ "))) | 307 | if (0 == strncasecmp (line, |
308 | "@INLINE@ ", | ||
309 | strlen ("@INLINE@ "))) | ||
305 | { | 310 | { |
306 | /* @INLINE@ value */ | 311 | /* @INLINE@ value */ |
307 | value = &line[strlen ("@INLINE@ ")]; | 312 | value = &line[strlen ("@INLINE@ ")]; |
308 | if (NULL != basedir) | 313 | if (NULL != basedir) |
309 | { | 314 | { |
310 | char *fn; | 315 | if ('/' == *value) |
311 | 316 | { | |
312 | GNUNET_asprintf (&fn, "%s/%s", basedir, value); | 317 | if (GNUNET_OK != |
313 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, fn)) | 318 | GNUNET_CONFIGURATION_parse (cfg, |
319 | value)) | ||
320 | { | ||
321 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
322 | break; | ||
323 | } | ||
324 | } | ||
325 | else | ||
314 | { | 326 | { |
327 | char *fn; | ||
328 | |||
329 | GNUNET_asprintf (&fn, "%s/%s", | ||
330 | basedir, | ||
331 | value); | ||
332 | if (GNUNET_OK != | ||
333 | GNUNET_CONFIGURATION_parse (cfg, | ||
334 | fn)) | ||
335 | { | ||
336 | GNUNET_free (fn); | ||
337 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
338 | break; | ||
339 | } | ||
315 | GNUNET_free (fn); | 340 | GNUNET_free (fn); |
316 | ret = GNUNET_SYSERR; /* failed to parse included config */ | ||
317 | break; | ||
318 | } | 341 | } |
319 | GNUNET_free (fn); | ||
320 | } | 342 | } |
321 | else | 343 | else |
322 | { | 344 | { |
@@ -374,7 +396,8 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
374 | } | 396 | } |
375 | GNUNET_free (line_orig); | 397 | GNUNET_free (line_orig); |
376 | GNUNET_free (section); | 398 | GNUNET_free (section); |
377 | GNUNET_assert ((GNUNET_OK != ret) || (r_bytes == size)); | 399 | GNUNET_assert ( (GNUNET_OK != ret) || |
400 | (r_bytes == size) ); | ||
378 | return ret; | 401 | return ret; |
379 | } | 402 | } |
380 | 403 | ||
@@ -426,7 +449,16 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
426 | endsep = strrchr (fn, (int) '/'); | 449 | endsep = strrchr (fn, (int) '/'); |
427 | if (NULL != endsep) | 450 | if (NULL != endsep) |
428 | *endsep = '\0'; | 451 | *endsep = '\0'; |
429 | ret = GNUNET_CONFIGURATION_deserialize (cfg, mem, fs, fn); | 452 | ret = GNUNET_CONFIGURATION_deserialize (cfg, |
453 | mem, | ||
454 | fs, | ||
455 | fn); | ||
456 | if (GNUNET_OK != ret) | ||
457 | { | ||
458 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
459 | _ ("Failed to parse configuration file `%s'\n"), | ||
460 | fn); | ||
461 | } | ||
430 | GNUNET_free (fn); | 462 | GNUNET_free (fn); |
431 | GNUNET_free (mem); | 463 | GNUNET_free (mem); |
432 | /* restore dirty flag - anything we set in the meantime | 464 | /* restore dirty flag - anything we set in the meantime |
diff --git a/src/util/gnunet-base32.c b/src/util/gnunet-base32.c index 2c797f56e..217185ed0 100644 --- a/src/util/gnunet-base32.c +++ b/src/util/gnunet-base32.c | |||
@@ -42,7 +42,8 @@ main (int argc, | |||
42 | const struct GNUNET_GETOPT_CommandLineOption options[] = { | 42 | const struct GNUNET_GETOPT_CommandLineOption options[] = { |
43 | GNUNET_GETOPT_option_flag ('d', | 43 | GNUNET_GETOPT_option_flag ('d', |
44 | "decode", | 44 | "decode", |
45 | gettext_noop ("run decoder modus, otherwise runs as encoder"), | 45 | gettext_noop ( |
46 | "run decoder modus, otherwise runs as encoder"), | ||
46 | &decode), | 47 | &decode), |
47 | GNUNET_GETOPT_option_help ("Crockford base32 encoder/decoder"), | 48 | GNUNET_GETOPT_option_help ("Crockford base32 encoder/decoder"), |
48 | GNUNET_GETOPT_option_version (PACKAGE_VERSION), | 49 | GNUNET_GETOPT_option_version (PACKAGE_VERSION), |
@@ -105,11 +106,12 @@ main (int argc, | |||
105 | out_size and out_size-1 below */ | 106 | out_size and out_size-1 below */ |
106 | out_size = in_size * 5 / 8; | 107 | out_size = in_size * 5 / 8; |
107 | out = GNUNET_malloc (out_size); | 108 | out = GNUNET_malloc (out_size); |
108 | if (GNUNET_OK != | 109 | if ( (GNUNET_OK != |
109 | GNUNET_STRINGS_string_to_data (in, | 110 | GNUNET_STRINGS_string_to_data (in, |
110 | in_size, | 111 | in_size, |
111 | out, | 112 | out, |
112 | out_size)) | 113 | out_size)) && |
114 | (out_size > 0) ) | ||
113 | { | 115 | { |
114 | out_size--; | 116 | out_size--; |
115 | if (GNUNET_OK != | 117 | if (GNUNET_OK != |