diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-05-15 16:08:33 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-05-15 16:08:33 +0200 |
commit | b030e5cc9520fc55a487d245b71db43157c6b4a1 (patch) | |
tree | 4cd14b3549a1537543baa93dd1482af45be74b71 /src/transport/gnunet-communicator-tcp.c | |
parent | c0b53f04253bea5b500194f3b3b4f41b444b1065 (diff) | |
download | gnunet-b030e5cc9520fc55a487d245b71db43157c6b4a1.tar.gz gnunet-b030e5cc9520fc55a487d245b71db43157c6b4a1.zip |
-coverity, remove commented code
Diffstat (limited to 'src/transport/gnunet-communicator-tcp.c')
-rw-r--r-- | src/transport/gnunet-communicator-tcp.c | 91 |
1 files changed, 31 insertions, 60 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index a871d980f..1b838bf9c 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -1158,10 +1158,10 @@ setup_cipher (const struct GNUNET_HashCode *dh, | |||
1158 | char key[256 / 8]; | 1158 | char key[256 / 8]; |
1159 | char ctr[128 / 8]; | 1159 | char ctr[128 / 8]; |
1160 | 1160 | ||
1161 | gcry_cipher_open (cipher, | 1161 | GNUNET_assert (0 == gcry_cipher_open (cipher, |
1162 | GCRY_CIPHER_AES256 /* low level: go for speed */, | 1162 | GCRY_CIPHER_AES256 /* low level: go for speed */, |
1163 | GCRY_CIPHER_MODE_CTR, | 1163 | GCRY_CIPHER_MODE_CTR, |
1164 | 0 /* flags */); | 1164 | 0 /* flags */)); |
1165 | GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (key, | 1165 | GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (key, |
1166 | sizeof(key), | 1166 | sizeof(key), |
1167 | "TCP-key", | 1167 | "TCP-key", |
@@ -1172,7 +1172,7 @@ setup_cipher (const struct GNUNET_HashCode *dh, | |||
1172 | sizeof(*pid), | 1172 | sizeof(*pid), |
1173 | NULL, | 1173 | NULL, |
1174 | 0)); | 1174 | 0)); |
1175 | gcry_cipher_setkey (*cipher, key, sizeof(key)); | 1175 | GNUNET_assert (0 == gcry_cipher_setkey (*cipher, key, sizeof(key))); |
1176 | GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (ctr, | 1176 | GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_kdf (ctr, |
1177 | sizeof(ctr), | 1177 | sizeof(ctr), |
1178 | "TCP-ctr", | 1178 | "TCP-ctr", |
@@ -2115,6 +2115,7 @@ extract_address (const char *bindto) | |||
2115 | char *token; | 2115 | char *token; |
2116 | char *cp; | 2116 | char *cp; |
2117 | char *rest = NULL; | 2117 | char *rest = NULL; |
2118 | char *res; | ||
2118 | 2119 | ||
2119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2120 | "extract address with bindto %s\n", | 2121 | "extract address with bindto %s\n", |
@@ -2145,7 +2146,9 @@ extract_address (const char *bindto) | |||
2145 | else | 2146 | else |
2146 | { | 2147 | { |
2147 | token++; | 2148 | token++; |
2148 | return token; | 2149 | res = GNUNET_strdup (token); |
2150 | GNUNET_free (cp); | ||
2151 | return res; | ||
2149 | } | 2152 | } |
2150 | } | 2153 | } |
2151 | 2154 | ||
@@ -2155,7 +2158,7 @@ extract_address (const char *bindto) | |||
2155 | "extract address with start %s\n", | 2158 | "extract address with start %s\n", |
2156 | start); | 2159 | start); |
2157 | 2160 | ||
2158 | return start; | 2161 | return GNUNET_strdup (start); |
2159 | } | 2162 | } |
2160 | 2163 | ||
2161 | 2164 | ||
@@ -2185,6 +2188,7 @@ extract_port (const char *addr_and_port) | |||
2185 | colon = strrchr (cp, ':'); | 2188 | colon = strrchr (cp, ':'); |
2186 | if (NULL == colon) | 2189 | if (NULL == colon) |
2187 | { | 2190 | { |
2191 | GNUNET_free (cp); | ||
2188 | return 0; | 2192 | return 0; |
2189 | } | 2193 | } |
2190 | addr = colon; | 2194 | addr = colon; |
@@ -2195,6 +2199,7 @@ extract_port (const char *addr_and_port) | |||
2195 | token = strtok_r (NULL, "]", &rest); | 2199 | token = strtok_r (NULL, "]", &rest); |
2196 | if (NULL == token) | 2200 | if (NULL == token) |
2197 | { | 2201 | { |
2202 | GNUNET_free (cp); | ||
2198 | return 0; | 2203 | return 0; |
2199 | } | 2204 | } |
2200 | else | 2205 | else |
@@ -2213,7 +2218,7 @@ extract_port (const char *addr_and_port) | |||
2213 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2218 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2214 | "Port `%u' invalid: value too large for port\n", | 2219 | "Port `%u' invalid: value too large for port\n", |
2215 | port); | 2220 | port); |
2216 | // GNUNET_free (cp); | 2221 | GNUNET_free (cp); |
2217 | return 0; | 2222 | return 0; |
2218 | } | 2223 | } |
2219 | } | 2224 | } |
@@ -2221,7 +2226,7 @@ extract_port (const char *addr_and_port) | |||
2221 | { | 2226 | { |
2222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2227 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2223 | "BINDTO specification invalid: last ':' not followed by number\n"); | 2228 | "BINDTO specification invalid: last ':' not followed by number\n"); |
2224 | // GNUNET_free (cp); | 2229 | GNUNET_free (cp); |
2225 | return 0; | 2230 | return 0; |
2226 | } | 2231 | } |
2227 | } | 2232 | } |
@@ -2252,7 +2257,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
2252 | unsigned int port; | 2257 | unsigned int port; |
2253 | struct sockaddr_in v4; | 2258 | struct sockaddr_in v4; |
2254 | struct sockaddr_in6 v6; | 2259 | struct sockaddr_in6 v6; |
2255 | const char *start; | 2260 | char *start; |
2256 | 2261 | ||
2257 | // cp = GNUNET_strdup (bindto); | 2262 | // cp = GNUNET_strdup (bindto); |
2258 | start = extract_address (bindto); | 2263 | start = extract_address (bindto); |
@@ -2288,8 +2293,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
2288 | GNUNET_assert (0); | 2293 | GNUNET_assert (0); |
2289 | } | 2294 | } |
2290 | 2295 | ||
2291 | // GNUNET_free (start); | 2296 | GNUNET_free (start); |
2292 | |||
2293 | return in; | 2297 | return in; |
2294 | } | 2298 | } |
2295 | 2299 | ||
@@ -2427,39 +2431,6 @@ boot_queue (struct Queue *queue) | |||
2427 | NULL, | 2431 | NULL, |
2428 | &mq_error, | 2432 | &mq_error, |
2429 | queue); | 2433 | queue); |
2430 | /* { */ | ||
2431 | /* char *foreign_addr; */ | ||
2432 | |||
2433 | /* switch (queue->address->sa_family) */ | ||
2434 | /* { */ | ||
2435 | /* case AF_INET: */ | ||
2436 | /* GNUNET_asprintf (&foreign_addr, */ | ||
2437 | /* "%s-%s", */ | ||
2438 | /* COMMUNICATOR_ADDRESS_PREFIX, */ | ||
2439 | /* GNUNET_a2s (queue->address, queue->address_len)); */ | ||
2440 | /* break; */ | ||
2441 | |||
2442 | /* case AF_INET6: */ | ||
2443 | /* GNUNET_asprintf (&foreign_addr, */ | ||
2444 | /* "%s-%s", */ | ||
2445 | /* COMMUNICATOR_ADDRESS_PREFIX, */ | ||
2446 | /* GNUNET_a2s (queue->address, queue->address_len)); */ | ||
2447 | /* break; */ | ||
2448 | |||
2449 | /* default: */ | ||
2450 | /* GNUNET_assert (0); */ | ||
2451 | /* } */ | ||
2452 | /* queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch, */ | ||
2453 | /* &queue->target, */ | ||
2454 | /* foreign_addr, */ | ||
2455 | /* 0 /\* no MTU *\/, */ | ||
2456 | /* GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, */ | ||
2457 | /* 0, /\* Priority *\/ */ | ||
2458 | /* queue->nt, */ | ||
2459 | /* queue->cs, */ | ||
2460 | /* queue->mq); */ | ||
2461 | /* GNUNET_free (foreign_addr); */ | ||
2462 | /* } */ | ||
2463 | } | 2434 | } |
2464 | 2435 | ||
2465 | 2436 | ||
@@ -2600,8 +2571,8 @@ handshake_monotime_cb (void *cls, | |||
2600 | pid, | 2571 | pid, |
2601 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, | 2572 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, |
2602 | handshake_monotonic_time, | 2573 | handshake_monotonic_time, |
2603 | sizeof( | 2574 | sizeof(* |
2604 | handshake_monotonic_time), | 2575 | handshake_monotonic_time), |
2605 | GNUNET_TIME_UNIT_FOREVER_ABS, | 2576 | GNUNET_TIME_UNIT_FOREVER_ABS, |
2606 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 2577 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
2607 | & | 2578 | & |
@@ -2642,18 +2613,18 @@ decrypt_and_check_tc (struct Queue *queue, | |||
2642 | memcpy (&ths.ephemeral, ibuf, sizeof(struct GNUNET_CRYPTO_EcdhePublicKey)); | 2613 | memcpy (&ths.ephemeral, ibuf, sizeof(struct GNUNET_CRYPTO_EcdhePublicKey)); |
2643 | ths.monotonic_time = tc->monotonic_time; | 2614 | ths.monotonic_time = tc->monotonic_time; |
2644 | ths.challenge = tc->challenge; | 2615 | ths.challenge = tc->challenge; |
2616 | queue->handshake_monotime_get = | ||
2617 | GNUNET_PEERSTORE_iterate (peerstore, | ||
2618 | "transport_tcp_communicator", | ||
2619 | &queue->target, | ||
2620 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, | ||
2621 | &handshake_monotime_cb, | ||
2622 | queue); | ||
2645 | return GNUNET_CRYPTO_eddsa_verify ( | 2623 | return GNUNET_CRYPTO_eddsa_verify ( |
2646 | GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE, | 2624 | GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE, |
2647 | &ths, | 2625 | &ths, |
2648 | &tc->sender_sig, | 2626 | &tc->sender_sig, |
2649 | &tc->sender.public_key); | 2627 | &tc->sender.public_key); |
2650 | queue->handshake_monotime_get = GNUNET_PEERSTORE_iterate (peerstore, | ||
2651 | "transport_tcp_communicator", | ||
2652 | &queue->target, | ||
2653 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, | ||
2654 | & | ||
2655 | handshake_monotime_cb, | ||
2656 | queue); | ||
2657 | } | 2628 | } |
2658 | 2629 | ||
2659 | 2630 | ||
@@ -2914,8 +2885,7 @@ queue_read_kx (void *cls) | |||
2914 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2915 | "cread_off set to %lu bytes\n", | 2886 | "cread_off set to %lu bytes\n", |
2916 | queue->cread_off); | 2887 | queue->cread_off); |
2917 | if (0 <= queue->cread_off) | 2888 | queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); |
2918 | queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); | ||
2919 | } | 2889 | } |
2920 | 2890 | ||
2921 | 2891 | ||
@@ -3359,10 +3329,11 @@ init_socket (struct sockaddr *addr, | |||
3359 | 3329 | ||
3360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3361 | "creating map entry\n"); | 3331 | "creating map entry\n"); |
3362 | GNUNET_CONTAINER_multihashmap_put (lt_map, | 3332 | GNUNET_assert (GNUNET_OK == |
3363 | &h_sock, | 3333 | GNUNET_CONTAINER_multihashmap_put (lt_map, |
3364 | lt, | 3334 | &h_sock, |
3365 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 3335 | lt, |
3336 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
3366 | 3337 | ||
3367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3368 | "map entry created\n"); | 3339 | "map entry created\n"); |