summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-03-26 22:32:12 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-03-26 22:32:12 +0100
commit33054bb2a8d6272e2f137e8be1833ff9e469c177 (patch)
treec78739fcf778dc56540877d255ae25766255a672 /src/transport
parent040ebbd2039e5ae0ba93ad3b7976721088ff6294 (diff)
-more coverity fixes
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-tcp.c48
-rw-r--r--src/transport/gnunet-communicator-udp.c13
-rw-r--r--src/transport/gnunet-service-tng.c6
-rw-r--r--src/transport/transport-testing-communicator.c5
4 files changed, 39 insertions, 33 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index c8a4c0375..9dd2797df 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -877,12 +877,14 @@ queue_destroy (struct Queue *queue)
{
struct ListenTask *lt = NULL;
struct GNUNET_HashCode h_sock;
+ int sockfd;
- GNUNET_CRYPTO_hash (queue->listen_sock,
- sizeof(queue->listen_sock),
+ sockfd = GNUNET_NETWORK_get_fd (queue->listen_sock);
+ GNUNET_CRYPTO_hash (&sockfd,
+ sizeof(int),
&h_sock);
- lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock);
+ lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting queue for peer `%s'\n",
@@ -1263,7 +1265,8 @@ rekey_monotime_cb (void *cls,
pid,
GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY,
rekey_monotonic_time,
- sizeof(rekey_monotonic_time),
+ sizeof(*
+ rekey_monotonic_time),
GNUNET_TIME_UNIT_FOREVER_ABS,
GNUNET_PEERSTORE_STOREOPTION_REPLACE,
&rekey_monotime_store_cb,
@@ -1413,18 +1416,18 @@ handshake_ack_monotime_cb (void *cls,
queue_finish (queue);
return;
}
- queue->handshake_ack_monotime_sc = GNUNET_PEERSTORE_store (peerstore,
- "transport_tcp_communicator",
- pid,
- GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK,
- handshake_ack_monotonic_time,
- sizeof(
- handshake_ack_monotonic_time),
- GNUNET_TIME_UNIT_FOREVER_ABS,
- GNUNET_PEERSTORE_STOREOPTION_REPLACE,
- &
- handshake_ack_monotime_store_cb,
- queue);
+ queue->handshake_ack_monotime_sc =
+ GNUNET_PEERSTORE_store (peerstore,
+ "transport_tcp_communicator",
+ pid,
+ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK,
+ handshake_ack_monotonic_time,
+ sizeof(*handshake_ack_monotonic_time),
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ GNUNET_PEERSTORE_STOREOPTION_REPLACE,
+ &
+ handshake_ack_monotime_store_cb,
+ queue);
}
@@ -3255,6 +3258,7 @@ init_socket (struct sockaddr *addr,
socklen_t sto_len;
struct GNUNET_NETWORK_Handle *listen_sock;
struct ListenTask *lt;
+ int sockfd;
struct GNUNET_HashCode h_sock;
if (NULL == addr)
@@ -3343,8 +3347,9 @@ init_socket (struct sockaddr *addr,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"creating hash\n");
- GNUNET_CRYPTO_hash (lt->listen_sock,
- sizeof(lt->listen_sock),
+ sockfd = GNUNET_NETWORK_get_fd (lt->listen_sock);
+ GNUNET_CRYPTO_hash (&sockfd,
+ sizeof(int),
&h_sock);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3564,6 +3569,7 @@ run (void *cls,
peerstore = GNUNET_PEERSTORE_connect (cfg);
if (NULL == peerstore)
{
+ GNUNET_free (bindto);
GNUNET_break (0);
GNUNET_SCHEDULER_shutdown ();
return;
@@ -3596,7 +3602,6 @@ run (void *cls,
GNUNET_free (po);
nat_register ();
GNUNET_free (bindto);
-
return;
}
@@ -3609,8 +3614,8 @@ run (void *cls,
in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port);
init_socket (in, in_len);
nat_register ();
+ GNUNET_free (start);
GNUNET_free (bindto);
-
return;
}
@@ -3620,8 +3625,8 @@ run (void *cls,
in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port);
init_socket (in, in_len);
nat_register ();
+ GNUNET_free (start);
GNUNET_free (bindto);
-
return;
}
@@ -3635,6 +3640,7 @@ run (void *cls,
&init_socket_resolv,
&port);
GNUNET_free (bindto);
+ GNUNET_free (start);
}
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 415dc4b48..d75f4ae00 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -1492,16 +1492,9 @@ add_acks (struct SharedSecret *ss, int acks_to_add)
struct ReceiverAddress *receiver = ss->receiver;
- if (NULL == ss)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "secret NULL!\n");
-
- if (NULL == receiver)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Receiver NULL!\n");
- if (NULL == receiver->d_qh)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Queue NULL!\n");
+ GNUNET_assert (NULL != ss);
+ GNUNET_assert (NULL != receiver);
+ GNUNET_assert (NULL != receiver->d_qh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Tell transport we have %u more acks!\n",
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 468048bec..cbf795eea 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -9639,11 +9639,13 @@ handle_add_queue_message (void *cls,
{
if (queue->qid != aqm->qid)
continue;
- neighbour = queue->neighbour;
break;
}
- if (NULL == queue)
+
+ if (NULL != queue)
{
+ neighbour = queue->neighbour;
+ } else {
neighbour = lookup_neighbour (&aqm->receiver);
if (NULL == neighbour)
{
diff --git a/src/transport/transport-testing-communicator.c b/src/transport/transport-testing-communicator.c
index de356fb9c..040f16d5d 100644
--- a/src/transport/transport-testing-communicator.c
+++ b/src/transport/transport-testing-communicator.c
@@ -548,6 +548,11 @@ handle_update_queue_message (void *cls,
tc_queue = tc_queue->next;
}
}
+ if (NULL == tc_queue)
+ {
+ GNUNET_SERVICE_client_continue (client->client);
+ return;
+ }
GNUNET_assert (tc_queue->qid == msg->qid);
GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
tc_queue->nt = msg->nt;