diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-08 17:20:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-08 17:20:23 +0000 |
commit | d8c53b12a818ff7cf82d06a1a69c395bdef85ee6 (patch) | |
tree | 0ebb0db416c157fcfde51a941185819dd12d51fd /src/cadet | |
parent | 5184c17d32a39c928c2a0fec3ee1ad098bbaa562 (diff) | |
download | gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.tar.gz gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.zip |
-avoid calling memcpy() with NULL argument, even if len is 0
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/cadet_api.c | 6 | ||||
-rw-r--r-- | src/cadet/cadet_common.c | 4 | ||||
-rw-r--r-- | src/cadet/cadet_path.c | 2 | ||||
-rw-r--r-- | src/cadet/cadet_tunnel_tree.c | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-cadet-profiler.c | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-cadet.c | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.c | 6 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_dht.c | 4 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_local.c | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.c | 4 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnel.c | 6 |
12 files changed, 21 insertions, 21 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 960f4788c..1ad3ec5b0 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -1410,7 +1410,7 @@ send_callback (void *cls, size_t size, void *buf) | |||
1410 | mh = (const struct GNUNET_MessageHeader *) &th[1]; | 1410 | mh = (const struct GNUNET_MessageHeader *) &th[1]; |
1411 | LOG (GNUNET_ERROR_TYPE_DEBUG, "# cadet internal traffic, type %s\n", | 1411 | LOG (GNUNET_ERROR_TYPE_DEBUG, "# cadet internal traffic, type %s\n", |
1412 | GC_m2s (ntohs (mh->type))); | 1412 | GC_m2s (ntohs (mh->type))); |
1413 | memcpy (cbuf, &th[1], th->size); | 1413 | GNUNET_memcpy (cbuf, &th[1], th->size); |
1414 | psize = th->size; | 1414 | psize = th->size; |
1415 | } | 1415 | } |
1416 | GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= psize); | 1416 | GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= psize); |
@@ -1478,7 +1478,7 @@ send_packet (struct GNUNET_CADET_Handle *h, | |||
1478 | th->timeout = GNUNET_TIME_UNIT_FOREVER_ABS; | 1478 | th->timeout = GNUNET_TIME_UNIT_FOREVER_ABS; |
1479 | th->size = msize; | 1479 | th->size = msize; |
1480 | th->channel = channel; | 1480 | th->channel = channel; |
1481 | memcpy (&th[1], msg, msize); | 1481 | GNUNET_memcpy (&th[1], msg, msize); |
1482 | add_to_queue (h, th); | 1482 | add_to_queue (h, th); |
1483 | if (NULL != h->th) | 1483 | if (NULL != h->th) |
1484 | return; | 1484 | return; |
@@ -2098,7 +2098,7 @@ cadet_mq_ntr (void *cls, size_t size, | |||
2098 | } | 2098 | } |
2099 | msize = ntohs (msg->size); | 2099 | msize = ntohs (msg->size); |
2100 | GNUNET_assert (msize <= size); | 2100 | GNUNET_assert (msize <= size); |
2101 | memcpy (buf, msg, msize); | 2101 | GNUNET_memcpy (buf, msg, msize); |
2102 | GNUNET_MQ_impl_send_continue (mq); | 2102 | GNUNET_MQ_impl_send_continue (mq); |
2103 | return msize; | 2103 | return msize; |
2104 | } | 2104 | } |
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c index 08e95bbdb..2376722fa 100644 --- a/src/cadet/cadet_common.c +++ b/src/cadet/cadet_common.c | |||
@@ -81,7 +81,7 @@ const struct GNUNET_HashCode * | |||
81 | GC_h2hc (const struct GNUNET_CADET_Hash *id) | 81 | GC_h2hc (const struct GNUNET_CADET_Hash *id) |
82 | { | 82 | { |
83 | static struct GNUNET_HashCode hc; | 83 | static struct GNUNET_HashCode hc; |
84 | memcpy (&hc, id, sizeof (*id)); | 84 | GNUNET_memcpy (&hc, id, sizeof (*id)); |
85 | 85 | ||
86 | return &hc; | 86 | return &hc; |
87 | } | 87 | } |
@@ -92,7 +92,7 @@ GC_h2s (const struct GNUNET_CADET_Hash *id) | |||
92 | { | 92 | { |
93 | static char s[53]; | 93 | static char s[53]; |
94 | 94 | ||
95 | memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52); | 95 | GNUNET_memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52); |
96 | s[52] = '\0'; | 96 | s[52] = '\0'; |
97 | 97 | ||
98 | return s; | 98 | return s; |
diff --git a/src/cadet/cadet_path.c b/src/cadet/cadet_path.c index 0358d64ca..277a7665a 100644 --- a/src/cadet/cadet_path.c +++ b/src/cadet/cadet_path.c | |||
@@ -110,7 +110,7 @@ path_duplicate (const struct CadetPeerPath *path) | |||
110 | unsigned int i; | 110 | unsigned int i; |
111 | 111 | ||
112 | aux = path_new (path->length); | 112 | aux = path_new (path->length); |
113 | memcpy (aux->peers, | 113 | GNUNET_memcpy (aux->peers, |
114 | path->peers, | 114 | path->peers, |
115 | path->length * sizeof (GNUNET_PEER_Id)); | 115 | path->length * sizeof (GNUNET_PEER_Id)); |
116 | for (i = 0; i < aux->length; i++) | 116 | for (i = 0; i < aux->length; i++) |
diff --git a/src/cadet/cadet_tunnel_tree.c b/src/cadet/cadet_tunnel_tree.c index 8ea012a36..81a38e4e8 100644 --- a/src/cadet/cadet_tunnel_tree.c +++ b/src/cadet/cadet_tunnel_tree.c | |||
@@ -161,7 +161,7 @@ path_duplicate (struct CadetPeerPath *path) | |||
161 | unsigned int i; | 161 | unsigned int i; |
162 | 162 | ||
163 | aux = path_new (path->length); | 163 | aux = path_new (path->length); |
164 | memcpy (aux->peers, path->peers, path->length * sizeof (GNUNET_PEER_Id)); | 164 | GNUNET_memcpy (aux->peers, path->peers, path->length * sizeof (GNUNET_PEER_Id)); |
165 | for (i = 0; i < path->length; i++) | 165 | for (i = 0; i < path->length; i++) |
166 | GNUNET_PEER_change_rc (path->peers[i], 1); | 166 | GNUNET_PEER_change_rc (path->peers[i], 1); |
167 | return aux; | 167 | return aux; |
diff --git a/src/cadet/gnunet-cadet-profiler.c b/src/cadet/gnunet-cadet-profiler.c index aa095d190..65e8f3219 100644 --- a/src/cadet/gnunet-cadet-profiler.c +++ b/src/cadet/gnunet-cadet-profiler.c | |||
@@ -621,7 +621,7 @@ tmt_rdy_pong (void *cls, size_t size, void *buf) | |||
621 | return 0; | 621 | return 0; |
622 | } | 622 | } |
623 | pong = (struct CadetPingMessage *) buf; | 623 | pong = (struct CadetPingMessage *) buf; |
624 | memcpy (pong, ping, sizeof (*ping)); | 624 | GNUNET_memcpy (pong, ping, sizeof (*ping)); |
625 | pong->header.type = htons (PONG); | 625 | pong->header.type = htons (PONG); |
626 | 626 | ||
627 | GNUNET_free (ping); | 627 | GNUNET_free (ping); |
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index f24975203..cf415448f 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -274,7 +274,7 @@ data_ready (void *cls, size_t size, void *buf) | |||
274 | msg = buf; | 274 | msg = buf; |
275 | msg->size = htons (total_size); | 275 | msg->size = htons (total_size); |
276 | msg->type = htons (GNUNET_MESSAGE_TYPE_CADET_CLI); | 276 | msg->type = htons (GNUNET_MESSAGE_TYPE_CADET_CLI); |
277 | memcpy (&msg[1], cls, data_size); | 277 | GNUNET_memcpy (&msg[1], cls, data_size); |
278 | if (GNUNET_NO == echo) | 278 | if (GNUNET_NO == echo) |
279 | { | 279 | { |
280 | listen_stdio (); | 280 | listen_stdio (); |
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index d4f9754da..3d204e5b3 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -379,7 +379,7 @@ copy_message (const struct GNUNET_CADET_Data *msg, uint32_t mid, | |||
379 | copy->mid = mid; | 379 | copy->mid = mid; |
380 | copy->rel = rel; | 380 | copy->rel = rel; |
381 | copy->type = GNUNET_MESSAGE_TYPE_CADET_DATA; | 381 | copy->type = GNUNET_MESSAGE_TYPE_CADET_DATA; |
382 | memcpy (©[1], msg, size); | 382 | GNUNET_memcpy (©[1], msg, size); |
383 | 383 | ||
384 | return copy; | 384 | return copy; |
385 | } | 385 | } |
@@ -1232,7 +1232,7 @@ channel_save_copy (struct CadetChannel *ch, | |||
1232 | copy->mid = mid; | 1232 | copy->mid = mid; |
1233 | copy->rel = rel; | 1233 | copy->rel = rel; |
1234 | copy->type = type; | 1234 | copy->type = type; |
1235 | memcpy (©[1], msg, size); | 1235 | GNUNET_memcpy (©[1], msg, size); |
1236 | GNUNET_CONTAINER_DLL_insert_tail (rel->head_sent, rel->tail_sent, copy); | 1236 | GNUNET_CONTAINER_DLL_insert_tail (rel->head_sent, rel->tail_sent, copy); |
1237 | ch->pending_messages++; | 1237 | ch->pending_messages++; |
1238 | 1238 | ||
@@ -1772,7 +1772,7 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1772 | payload = (struct GNUNET_CADET_Data *) cbuf; | 1772 | payload = (struct GNUNET_CADET_Data *) cbuf; |
1773 | payload->mid = htonl (rel->mid_send); | 1773 | payload->mid = htonl (rel->mid_send); |
1774 | rel->mid_send++; | 1774 | rel->mid_send++; |
1775 | memcpy (&payload[1], message, size); | 1775 | GNUNET_memcpy (&payload[1], message, size); |
1776 | payload->header.size = htons (p2p_size); | 1776 | payload->header.size = htons (p2p_size); |
1777 | payload->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_DATA); | 1777 | payload->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_DATA); |
1778 | payload->chid = htonl (ch->gid); | 1778 | payload->chid = htonl (ch->gid); |
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 188041feb..9dfecf043 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -3484,7 +3484,7 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
3484 | GCC_check_connections (); | 3484 | GCC_check_connections (); |
3485 | size = ntohs (message->size); | 3485 | size = ntohs (message->size); |
3486 | data = GNUNET_malloc (size); | 3486 | data = GNUNET_malloc (size); |
3487 | memcpy (data, message, size); | 3487 | GNUNET_memcpy (data, message, size); |
3488 | type = ntohs (message->type); | 3488 | type = ntohs (message->type); |
3489 | LOG (GNUNET_ERROR_TYPE_INFO, | 3489 | LOG (GNUNET_ERROR_TYPE_INFO, |
3490 | "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n", | 3490 | "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n", |
diff --git a/src/cadet/gnunet-service-cadet_dht.c b/src/cadet/gnunet-service-cadet_dht.c index da9bf7604..55dd10d33 100644 --- a/src/cadet/gnunet-service-cadet_dht.c +++ b/src/cadet/gnunet-service-cadet_dht.c | |||
@@ -239,7 +239,7 @@ announce_id (void *cls) | |||
239 | GNUNET_STATISTICS_update (stats, "# DHT announce", | 239 | GNUNET_STATISTICS_update (stats, "# DHT announce", |
240 | 1, GNUNET_NO); | 240 | 1, GNUNET_NO); |
241 | memset (&phash, 0, sizeof (phash)); | 241 | memset (&phash, 0, sizeof (phash)); |
242 | memcpy (&phash, &my_full_id, sizeof (my_full_id)); | 242 | GNUNET_memcpy (&phash, &my_full_id, sizeof (my_full_id)); |
243 | GNUNET_DHT_put (dht_handle, /* DHT handle */ | 243 | GNUNET_DHT_put (dht_handle, /* DHT handle */ |
244 | &phash, /* Key to use */ | 244 | &phash, /* Key to use */ |
245 | dht_replication_level, /* Replication level */ | 245 | dht_replication_level, /* Replication level */ |
@@ -352,7 +352,7 @@ GCD_search (const struct GNUNET_PeerIdentity *peer_id, | |||
352 | GNUNET_i2s (peer_id)); | 352 | GNUNET_i2s (peer_id)); |
353 | GNUNET_STATISTICS_update (stats, "# DHT search", 1, GNUNET_NO); | 353 | GNUNET_STATISTICS_update (stats, "# DHT search", 1, GNUNET_NO); |
354 | memset (&phash, 0, sizeof (phash)); | 354 | memset (&phash, 0, sizeof (phash)); |
355 | memcpy (&phash, peer_id, sizeof (*peer_id)); | 355 | GNUNET_memcpy (&phash, peer_id, sizeof (*peer_id)); |
356 | h = GNUNET_new (struct GCD_search_handle); | 356 | h = GNUNET_new (struct GCD_search_handle); |
357 | h->peer_id = GNUNET_PEER_intern (peer_id); | 357 | h->peer_id = GNUNET_PEER_intern (peer_id); |
358 | h->callback = callback; | 358 | h->callback = callback; |
diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c index 0a7c3d14d..ce1f45a10 100644 --- a/src/cadet/gnunet-service-cadet_local.c +++ b/src/cadet/gnunet-service-cadet_local.c | |||
@@ -1487,7 +1487,7 @@ GML_send_data (struct CadetClient *c, | |||
1487 | return; | 1487 | return; |
1488 | } | 1488 | } |
1489 | copy = (struct GNUNET_CADET_LocalData *) cbuf; | 1489 | copy = (struct GNUNET_CADET_LocalData *) cbuf; |
1490 | memcpy (©[1], &msg[1], size); | 1490 | GNUNET_memcpy (©[1], &msg[1], size); |
1491 | copy->header.size = htons (sizeof (struct GNUNET_CADET_LocalData) + size); | 1491 | copy->header.size = htons (sizeof (struct GNUNET_CADET_LocalData) + size); |
1492 | copy->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); | 1492 | copy->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); |
1493 | copy->id = htonl (id); | 1493 | copy->id = htonl (id); |
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 22a8150c4..e19c3ca48 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -604,7 +604,7 @@ send_core_data_raw (void *cls, size_t size, void *buf) | |||
604 | GNUNET_break (0); | 604 | GNUNET_break (0); |
605 | return 0; | 605 | return 0; |
606 | } | 606 | } |
607 | memcpy (buf, msg, total_size); | 607 | GNUNET_memcpy (buf, msg, total_size); |
608 | GNUNET_free (cls); | 608 | GNUNET_free (cls); |
609 | return total_size; | 609 | return total_size; |
610 | } | 610 | } |
@@ -2518,7 +2518,7 @@ GCP_set_hello (struct CadetPeer *peer, | |||
2518 | { | 2518 | { |
2519 | size = GNUNET_HELLO_size (hello); | 2519 | size = GNUNET_HELLO_size (hello); |
2520 | peer->hello = GNUNET_malloc (size); | 2520 | peer->hello = GNUNET_malloc (size); |
2521 | memcpy (peer->hello, hello, size); | 2521 | GNUNET_memcpy (peer->hello, hello, size); |
2522 | } | 2522 | } |
2523 | else | 2523 | else |
2524 | { | 2524 | { |
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index b9f0e1fa2..fe763e655 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c | |||
@@ -923,7 +923,7 @@ t_hmac (const void *plaintext, size_t size, | |||
923 | NULL); | 923 | NULL); |
924 | /* Two step: CADET_Hash is only 256 bits, HashCode is 512. */ | 924 | /* Two step: CADET_Hash is only 256 bits, HashCode is 512. */ |
925 | GNUNET_CRYPTO_hmac (&auth_key, plaintext, size, &hash); | 925 | GNUNET_CRYPTO_hmac (&auth_key, plaintext, size, &hash); |
926 | memcpy (hmac, &hash, sizeof (*hmac)); | 926 | GNUNET_memcpy (hmac, &hash, sizeof (*hmac)); |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
@@ -1885,7 +1885,7 @@ queue_data (struct CadetTunnel *t, const struct GNUNET_MessageHeader *msg) | |||
1885 | tqd = GNUNET_malloc (sizeof (struct CadetTunnelDelayed) + size); | 1885 | tqd = GNUNET_malloc (sizeof (struct CadetTunnelDelayed) + size); |
1886 | 1886 | ||
1887 | tqd->t = t; | 1887 | tqd->t = t; |
1888 | memcpy (&tqd[1], msg, size); | 1888 | GNUNET_memcpy (&tqd[1], msg, size); |
1889 | GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tqd); | 1889 | GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tqd); |
1890 | return tqd; | 1890 | return tqd; |
1891 | } | 1891 | } |
@@ -2246,7 +2246,7 @@ send_kx (struct CadetTunnel *t, | |||
2246 | LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", GC_m2s (type)); | 2246 | LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", GC_m2s (type)); |
2247 | GNUNET_assert (0); | 2247 | GNUNET_assert (0); |
2248 | } | 2248 | } |
2249 | memcpy (&msg[1], message, size); | 2249 | GNUNET_memcpy (&msg[1], message, size); |
2250 | 2250 | ||
2251 | fwd = GCC_is_origin (c, GNUNET_YES); | 2251 | fwd = GCC_is_origin (c, GNUNET_YES); |
2252 | 2252 | ||