aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-11-01 11:32:39 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-11-01 11:32:39 +0900
commit0f45038d25da3d3de3f83d04bcf30eca5da361d0 (patch)
tree7eb579ded346186c26e65ecd3ce0b882904f3301
parent3cf47c04e2de3e3f275398f4dbc223fdaeea6aff (diff)
downloadgnunet-0f45038d25da3d3de3f83d04bcf30eca5da361d0.tar.gz
gnunet-0f45038d25da3d3de3f83d04bcf30eca5da361d0.zip
-fix coverity
-rw-r--r--src/conversation/gnunet-service-conversation.c19
-rw-r--r--src/gnsrecord/json_gnsrecord.c2
-rw-r--r--src/identity/identity_api.c5
-rw-r--r--src/messenger/gnunet-service-messenger.c10
-rw-r--r--src/namestore/gnunet-service-namestore.c1
-rw-r--r--src/reclaim/gnunet-service-reclaim.c2
-rw-r--r--src/revocation/plugin_block_revocation.c29
-rw-r--r--src/testing/testing.c45
8 files changed, 67 insertions, 46 deletions
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c
index a551bed1a..1fff8bd26 100644
--- a/src/conversation/gnunet-service-conversation.c
+++ b/src/conversation/gnunet-service-conversation.c
@@ -738,7 +738,7 @@ handle_client_audio_message (void *cls, const struct ClientAudioMessage *msg)
738static enum GNUNET_GenericReturnValue 738static enum GNUNET_GenericReturnValue
739check_cadet_ring_message (void *cls, const struct CadetPhoneRingMessage *msg) 739check_cadet_ring_message (void *cls, const struct CadetPhoneRingMessage *msg)
740{ 740{
741 //FIXME 741 // FIXME
742 return GNUNET_OK; 742 return GNUNET_OK;
743} 743}
744 744
@@ -1181,6 +1181,18 @@ handle_client_call_message (void *cls, const struct ClientCallMessage *msg)
1181 rs.target_peer = msg->target; 1181 rs.target_peer = msg->target;
1182 rs.expiration_time = 1182 rs.expiration_time =
1183 GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (RING_TIMEOUT)); 1183 GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (RING_TIMEOUT));
1184 key_len = ntohl (msg->key_len);
1185 if (GNUNET_SYSERR ==
1186 GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1],
1187 key_len,
1188 &caller_id,
1189 &read))
1190 {
1191 GNUNET_break_op (0);
1192 GNUNET_free (ch);
1193 GNUNET_SERVICE_client_drop (line->client);
1194 return;
1195 }
1184 ch->line = line; 1196 ch->line = line;
1185 GNUNET_CONTAINER_DLL_insert (line->channel_head, line->channel_tail, ch); 1197 GNUNET_CONTAINER_DLL_insert (line->channel_head, line->channel_tail, ch);
1186 ch->status = CS_CALLER_CALLING; 1198 ch->status = CS_CALLER_CALLING;
@@ -1192,11 +1204,6 @@ handle_client_call_message (void *cls, const struct ClientCallMessage *msg)
1192 &inbound_end, 1204 &inbound_end,
1193 cadet_handlers); 1205 cadet_handlers);
1194 ch->mq = GNUNET_CADET_get_mq (ch->channel); 1206 ch->mq = GNUNET_CADET_get_mq (ch->channel);
1195 key_len = ntohl (msg->key_len);
1196 GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1],
1197 key_len,
1198 &caller_id,
1199 &read);
1200 GNUNET_assert (read == key_len); 1207 GNUNET_assert (read == key_len);
1201 GNUNET_IDENTITY_sign (&caller_id, &rs, &sig); 1208 GNUNET_IDENTITY_sign (&caller_id, &rs, &sig);
1202 sig_len = GNUNET_IDENTITY_signature_get_length (&sig); 1209 sig_len = GNUNET_IDENTITY_signature_get_length (&sig);
diff --git a/src/gnsrecord/json_gnsrecord.c b/src/gnsrecord/json_gnsrecord.c
index 1c59d146e..2b840ab30 100644
--- a/src/gnsrecord/json_gnsrecord.c
+++ b/src/gnsrecord/json_gnsrecord.c
@@ -97,7 +97,7 @@ parse_record (json_t *data, struct GNUNET_GNSRECORD_Data *rd)
97 unpack_state = json_unpack_ex (data, 97 unpack_state = json_unpack_ex (data,
98 &err, 98 &err,
99 0, 99 0,
100 "{s:s, s:s, s:i, s:b, s:b, s:b, s:b}", 100 "{s:s, s:s, s:I, s:b, s:b, s:b, s:b}",
101 GNUNET_JSON_GNSRECORD_VALUE, 101 GNUNET_JSON_GNSRECORD_VALUE,
102 &value, 102 &value,
103 GNUNET_JSON_GNSRECORD_TYPE, 103 GNUNET_JSON_GNSRECORD_TYPE,
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 4abd62434..3fd052277 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -157,14 +157,17 @@ GNUNET_IDENTITY_ego_get_anonymous ()
157{ 157{
158 static struct GNUNET_IDENTITY_Ego anon; 158 static struct GNUNET_IDENTITY_Ego anon;
159 static int setup; 159 static int setup;
160 ssize_t key_len;
160 161
161 if (setup) 162 if (setup)
162 return &anon; 163 return &anon;
163 anon.pk.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); 164 anon.pk.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
164 anon.pub.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); 165 anon.pub.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
165 anon.pk.ecdsa_key = *GNUNET_CRYPTO_ecdsa_key_get_anonymous (); 166 anon.pk.ecdsa_key = *GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
167 key_len = GNUNET_IDENTITY_private_key_get_length (&anon.pk);
168 GNUNET_assert (0 < key_len);
166 GNUNET_CRYPTO_hash (&anon.pk, 169 GNUNET_CRYPTO_hash (&anon.pk,
167 GNUNET_IDENTITY_private_key_get_length (&anon.pk), 170 key_len,
168 &anon.id); 171 &anon.id);
169 setup = 1; 172 setup = 1;
170 return &anon; 173 return &anon;
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index a2b6ad81e..a4b46773d 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -261,9 +261,13 @@ handle_send_message (void *cls,
261 struct GNUNET_IDENTITY_PublicKey public_key; 261 struct GNUNET_IDENTITY_PublicKey public_key;
262 262
263 if (flags & GNUNET_MESSENGER_FLAG_PRIVATE) 263 if (flags & GNUNET_MESSENGER_FLAG_PRIVATE)
264 GNUNET_IDENTITY_read_public_key_from_buffer ( 264 {
265 buffer, length, &public_key, &key_length); 265 GNUNET_assert (GNUNET_SYSERR !=
266 266 GNUNET_IDENTITY_read_public_key_from_buffer (buffer,
267 length,
268 &public_key,
269 &key_length));
270 }
267 const uint16_t msg_length = length - key_length; 271 const uint16_t msg_length = length - key_length;
268 const char*msg_buffer = buffer + key_length; 272 const char*msg_buffer = buffer + key_length;
269 273
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index f0739cbeb..9173d2e4d 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -2525,6 +2525,7 @@ handle_monitor_start (void *cls, const struct
2525 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2525 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2526 "Error reading private key\n"); 2526 "Error reading private key\n");
2527 GNUNET_SERVICE_client_drop (nc->client); 2527 GNUNET_SERVICE_client_drop (nc->client);
2528 GNUNET_free (zm);
2528 return; 2529 return;
2529 } 2530 }
2530 zm->zone = zone; 2531 zm->zone = zone;
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index ea97f8749..4c80d6d24 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -913,7 +913,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
913 buf += read; 913 buf += read;
914 tkt_len = ntohl (rm->tkt_len); 914 tkt_len = ntohl (rm->tkt_len);
915 if ((GNUNET_SYSERR == 915 if ((GNUNET_SYSERR ==
916 GNUNET_RECLAIM_read_ticket_from_buffer (buf, key_len, 916 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len,
917 &ticket, &read)) || 917 &ticket, &read)) ||
918 (read != tkt_len)) 918 (read != tkt_len))
919 { 919 {
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c
index 0c81440eb..7de4fafe9 100644
--- a/src/revocation/plugin_block_revocation.c
+++ b/src/revocation/plugin_block_revocation.c
@@ -114,11 +114,16 @@ block_plugin_revocation_check_block (void *cls,
114 return GNUNET_NO; 114 return GNUNET_NO;
115 } 115 }
116 left = block_size - sizeof (*rm) - sizeof (*pow); 116 left = block_size - sizeof (*rm) - sizeof (*pow);
117 GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1], 117 if (GNUNET_SYSERR ==
118 left, 118 GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1],
119 &pk, 119 left,
120 &pklen); 120 &pk,
121 if (0 > pklen) 121 &pklen))
122 {
123 GNUNET_break_op (0);
124 return GNUNET_NO;
125 }
126 if (0 == pklen)
122 { 127 {
123 GNUNET_break_op (0); 128 GNUNET_break_op (0);
124 return GNUNET_NO; 129 return GNUNET_NO;
@@ -219,11 +224,15 @@ block_plugin_revocation_get_key (void *cls,
219 return GNUNET_NO; 224 return GNUNET_NO;
220 } 225 }
221 left = block_size - sizeof (*rm) - sizeof (*pow); 226 left = block_size - sizeof (*rm) - sizeof (*pow);
222 GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1], 227 if (GNUNET_SYSERR == GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1],
223 left, 228 left,
224 &pk, 229 &pk,
225 &pklen); 230 &pklen))
226 if (0 > pklen) 231 {
232 GNUNET_break_op (0);
233 return GNUNET_NO;
234 }
235 if (0 == pklen)
227 { 236 {
228 GNUNET_break_op (0); 237 GNUNET_break_op (0);
229 return GNUNET_NO; 238 return GNUNET_NO;
diff --git a/src/testing/testing.c b/src/testing/testing.c
index e6f073f63..d18197860 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -2499,8 +2499,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2499 } 2499 }
2500 else if (0 == strcmp (key, "K")) 2500 else if (0 == strcmp (key, "K"))
2501 { 2501 {
2502 struct GNUNET_ShortHashCode *hkey_k = GNUNET_new (struct 2502 struct GNUNET_ShortHashCode hkey_k;
2503 GNUNET_ShortHashCode);
2504 struct GNUNET_TESTING_NetjailNode *k_node = GNUNET_new (struct 2503 struct GNUNET_TESTING_NetjailNode *k_node = GNUNET_new (struct
2505 GNUNET_TESTING_NetjailNode); 2504 GNUNET_TESTING_NetjailNode);
2506 2505
@@ -2512,18 +2511,18 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2512 out); 2511 out);
2513 k_node->node_n = out; 2512 k_node->node_n = out;
2514 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); 2513 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2515 memcpy (hkey_k, 2514 memcpy (&hkey_k,
2516 &hc, 2515 &hc,
2517 sizeof (*hkey_k)); 2516 sizeof (hkey_k));
2518 k_node->is_global = GNUNET_YES; 2517 k_node->is_global = GNUNET_YES;
2519 2518
2520 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( 2519 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
2521 topo->map_globals, 2520 topo->map_globals,
2522 hkey_k)) 2521 &hkey_k))
2523 GNUNET_break (0); 2522 GNUNET_break (0);
2524 else 2523 else
2525 GNUNET_CONTAINER_multishortmap_put (topo->map_globals, 2524 GNUNET_CONTAINER_multishortmap_put (topo->map_globals,
2526 hkey_k, 2525 &hkey_k,
2527 k_node, 2526 k_node,
2528 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2527 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2529 LOG (GNUNET_ERROR_TYPE_DEBUG, 2528 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2539,8 +2538,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2539 } 2538 }
2540 else if (0 == strcmp (key, "R")) 2539 else if (0 == strcmp (key, "R"))
2541 { 2540 {
2542 struct GNUNET_ShortHashCode *hkey_r = GNUNET_new (struct 2541 struct GNUNET_ShortHashCode hkey_r;
2543 GNUNET_ShortHashCode);
2544 router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter); 2542 router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter);
2545 2543
2546 LOG (GNUNET_ERROR_TYPE_DEBUG, 2544 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2550,9 +2548,9 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2550 "R: %u\n", 2548 "R: %u\n",
2551 out); 2549 out);
2552 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); 2550 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2553 memcpy (hkey_r, 2551 memcpy (&hkey_r,
2554 &hc, 2552 &hc,
2555 sizeof (*hkey_r)); 2553 sizeof (hkey_r));
2556 LOG (GNUNET_ERROR_TYPE_DEBUG, 2554 LOG (GNUNET_ERROR_TYPE_DEBUG,
2557 "Get value for key tcp_port on R.\n"); 2555 "Get value for key tcp_port on R.\n");
2558 value = get_value ("tcp_port", token); 2556 value = get_value ("tcp_port", token);
@@ -2575,10 +2573,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2575 GNUNET_free (value2); 2573 GNUNET_free (value2);
2576 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( 2574 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
2577 topo->map_namespaces, 2575 topo->map_namespaces,
2578 hkey_r)) 2576 &hkey_r))
2579 { 2577 {
2580 namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces, 2578 namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
2581 hkey_r); 2579 &hkey_r);
2582 } 2580 }
2583 else 2581 else
2584 { 2582 {
@@ -2586,7 +2584,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2586 namespace->namespace_n = out; 2584 namespace->namespace_n = out;
2587 namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); 2585 namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2588 GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces, 2586 GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces,
2589 hkey_r, 2587 &hkey_r,
2590 namespace, 2588 namespace,
2591 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2589 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2592 } 2590 }
@@ -2597,8 +2595,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2597 { 2595 {
2598 struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct 2596 struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct
2599 GNUNET_TESTING_NetjailNode); 2597 GNUNET_TESTING_NetjailNode);
2600 struct GNUNET_ShortHashCode *hkey_p = GNUNET_new (struct 2598 struct GNUNET_ShortHashCode hkey_p;
2601 GNUNET_ShortHashCode);
2602 2599
2603 LOG (GNUNET_ERROR_TYPE_DEBUG, 2600 LOG (GNUNET_ERROR_TYPE_DEBUG,
2604 "Get first Value for P.\n"); 2601 "Get first Value for P.\n");
@@ -2607,16 +2604,16 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2607 "P: %u\n", 2604 "P: %u\n",
2608 out); 2605 out);
2609 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); 2606 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2610 memcpy (hkey_p, 2607 memcpy (&hkey_p,
2611 &hc, 2608 &hc,
2612 sizeof (*hkey_p)); 2609 sizeof (hkey_p));
2613 2610
2614 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( 2611 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
2615 topo->map_namespaces, 2612 topo->map_namespaces,
2616 hkey_p)) 2613 &hkey_p))
2617 { 2614 {
2618 namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces, 2615 namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
2619 hkey_p); 2616 &hkey_p);
2620 } 2617 }
2621 else 2618 else
2622 { 2619 {
@@ -2624,7 +2621,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2624 namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); 2621 namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2625 namespace->namespace_n = out; 2622 namespace->namespace_n = out;
2626 GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces, 2623 GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces,
2627 hkey_p, 2624 &hkey_p,
2628 namespace, 2625 namespace,
2629 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2626 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2630 } 2627 }
@@ -2635,12 +2632,12 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2635 "P: %u\n", 2632 "P: %u\n",
2636 out); 2633 out);
2637 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); 2634 GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2638 memcpy (hkey_p, 2635 memcpy (&hkey_p,
2639 &hc, 2636 &hc,
2640 sizeof (*hkey_p)); 2637 sizeof (hkey_p));
2641 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( 2638 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
2642 namespace->nodes, 2639 namespace->nodes,
2643 hkey_p)) 2640 &hkey_p))
2644 { 2641 {
2645 GNUNET_break (0); 2642 GNUNET_break (0);
2646 } 2643 }
@@ -2648,7 +2645,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2648 { 2645 {
2649 2646
2650 GNUNET_CONTAINER_multishortmap_put (namespace->nodes, 2647 GNUNET_CONTAINER_multishortmap_put (namespace->nodes,
2651 hkey_p, 2648 &hkey_p,
2652 p_node, 2649 p_node,
2653 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2650 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2654 LOG (GNUNET_ERROR_TYPE_DEBUG, 2651 LOG (GNUNET_ERROR_TYPE_DEBUG,