aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-08 17:20:23 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-08 17:20:23 +0000
commitd8c53b12a818ff7cf82d06a1a69c395bdef85ee6 (patch)
tree0ebb0db416c157fcfde51a941185819dd12d51fd /src/core
parent5184c17d32a39c928c2a0fec3ee1ad098bbaa562 (diff)
downloadgnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.tar.gz
gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.zip
-avoid calling memcpy() with NULL argument, even if len is 0
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core_api.c2
-rw-r--r--src/core/core_api_mq.c2
-rw-r--r--src/core/gnunet-service-core_clients.c2
-rw-r--r--src/core/gnunet-service-core_kx.c2
-rw-r--r--src/core/gnunet-service-core_neighbours.c4
-rw-r--r--src/core/gnunet-service-core_sessions.c6
-rw-r--r--src/core/gnunet-service-core_typemap.c6
-rw-r--r--src/core/test_core_api_reliability.c2
-rw-r--r--src/core/test_core_api_send_to_self.c2
-rw-r--r--src/core/test_core_quota_compliance.c4
10 files changed, 16 insertions, 16 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 86c9d38a2..dd912ac22 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -891,7 +891,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
891 h->handlers = GNUNET_new_array (hcnt + 1, 891 h->handlers = GNUNET_new_array (hcnt + 1,
892 struct GNUNET_CORE_MessageHandler); 892 struct GNUNET_CORE_MessageHandler);
893 if (NULL != handlers) 893 if (NULL != handlers)
894 memcpy (h->handlers, 894 GNUNET_memcpy (h->handlers,
895 handlers, 895 handlers,
896 hcnt * sizeof (struct GNUNET_CORE_MessageHandler)); 896 hcnt * sizeof (struct GNUNET_CORE_MessageHandler));
897 h->hcnt = hcnt; 897 h->hcnt = hcnt;
diff --git a/src/core/core_api_mq.c b/src/core/core_api_mq.c
index 11e2214fd..12c7a3bdd 100644
--- a/src/core/core_api_mq.c
+++ b/src/core/core_api_mq.c
@@ -86,7 +86,7 @@ core_mq_ntr (void *cls, size_t size,
86 GNUNET_MQ_inject_error (mq, GNUNET_MQ_ERROR_WRITE); 86 GNUNET_MQ_inject_error (mq, GNUNET_MQ_ERROR_WRITE);
87 return 0; 87 return 0;
88 } 88 }
89 memcpy (buf, mh, msg_size); 89 GNUNET_memcpy (buf, mh, msg_size);
90 GNUNET_MQ_impl_send_continue (mq); 90 GNUNET_MQ_impl_send_continue (mq);
91 return msg_size; 91 return msg_size;
92} 92}
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c
index c2198848f..3030eb701 100644
--- a/src/core/gnunet-service-core_clients.c
+++ b/src/core/gnunet-service-core_clients.c
@@ -894,7 +894,7 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
894 else 894 else
895 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND); 895 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND);
896 ntm->peer = *sender; 896 ntm->peer = *sender;
897 memcpy (&ntm[1], 897 GNUNET_memcpy (&ntm[1],
898 msg, 898 msg,
899 msize); 899 msize);
900 send_to_all_clients (sender, 900 send_to_all_clients (sender,
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index 6a1924e54..f2d3e0492 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -1375,7 +1375,7 @@ GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
1375 ph->iv_seed = calculate_seed (kx); 1375 ph->iv_seed = calculate_seed (kx);
1376 ph->reserved = 0; 1376 ph->reserved = 0;
1377 ph->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1377 ph->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1378 memcpy (&ph[1], 1378 GNUNET_memcpy (&ph[1],
1379 payload, 1379 payload,
1380 payload_size); 1380 payload_size);
1381 1381
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c
index c1c62cf1a..c2f3ef805 100644
--- a/src/core/gnunet-service-core_neighbours.c
+++ b/src/core/gnunet-service-core_neighbours.c
@@ -261,7 +261,7 @@ transmit_ready (void *cls,
261 overdue = GNUNET_TIME_absolute_get_duration (m->deadline); 261 overdue = GNUNET_TIME_absolute_get_duration (m->deadline);
262 cbuf = buf; 262 cbuf = buf;
263 GNUNET_assert (size >= m->size); 263 GNUNET_assert (size >= m->size);
264 memcpy (cbuf, 264 GNUNET_memcpy (cbuf,
265 &m[1], 265 &m[1],
266 m->size); 266 m->size);
267 ret = m->size; 267 ret = m->size;
@@ -521,7 +521,7 @@ GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target,
521 me = GNUNET_malloc (sizeof (struct NeighbourMessageEntry) + msize); 521 me = GNUNET_malloc (sizeof (struct NeighbourMessageEntry) + msize);
522 me->deadline = GNUNET_TIME_relative_to_absolute (timeout); 522 me->deadline = GNUNET_TIME_relative_to_absolute (timeout);
523 me->size = msize; 523 me->size = msize;
524 memcpy (&me[1], 524 GNUNET_memcpy (&me[1],
525 msg, 525 msg,
526 msize); 526 msize);
527 GNUNET_CONTAINER_DLL_insert_tail (n->message_head, 527 GNUNET_CONTAINER_DLL_insert_tail (n->message_head,
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index 0a547be1b..41d3cc24b 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -747,7 +747,7 @@ try_transmission (struct Session *session)
747 while ( (NULL != (pos = session->sme_head)) && 747 while ( (NULL != (pos = session->sme_head)) &&
748 (used + pos->size <= msize) ) 748 (used + pos->size <= msize) )
749 { 749 {
750 memcpy (&pbuf[used], &pos[1], pos->size); 750 GNUNET_memcpy (&pbuf[used], &pos[1], pos->size);
751 used += pos->size; 751 used += pos->size;
752 GNUNET_CONTAINER_DLL_remove (session->sme_head, 752 GNUNET_CONTAINER_DLL_remove (session->sme_head,
753 session->sme_tail, 753 session->sme_tail,
@@ -797,7 +797,7 @@ do_restart_typemap_message (void *cls,
797 797
798 size = ntohs (hdr->size); 798 size = ntohs (hdr->size);
799 sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) + size); 799 sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) + size);
800 memcpy (&sme[1], hdr, size); 800 GNUNET_memcpy (&sme[1], hdr, size);
801 sme->size = size; 801 sme->size = size;
802 sme->priority = GNUNET_CORE_PRIO_CRITICAL_CONTROL; 802 sme->priority = GNUNET_CORE_PRIO_CRITICAL_CONTROL;
803 GNUNET_CONTAINER_DLL_insert (session->sme_head, 803 GNUNET_CONTAINER_DLL_insert (session->sme_head,
@@ -871,7 +871,7 @@ GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
871 return; 871 return;
872 msize = ntohs (msg->size); 872 msize = ntohs (msg->size);
873 sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) + msize); 873 sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) + msize);
874 memcpy (&sme[1], msg, msize); 874 GNUNET_memcpy (&sme[1], msg, msize);
875 sme->size = msize; 875 sme->size = msize;
876 sme->priority = priority; 876 sme->priority = priority;
877 if (GNUNET_YES == cork) 877 if (GNUNET_YES == cork)
diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c
index 0b3f93a26..d400c0b8b 100644
--- a/src/core/gnunet-service-core_typemap.c
+++ b/src/core/gnunet-service-core_typemap.c
@@ -136,7 +136,7 @@ GSC_TYPEMAP_compute_type_map_message ()
136 { 136 {
137 /* compression failed, use uncompressed map */ 137 /* compression failed, use uncompressed map */
138 dlen = sizeof (my_type_map); 138 dlen = sizeof (my_type_map);
139 memcpy (tmp, &my_type_map, sizeof (my_type_map)); 139 GNUNET_memcpy (tmp, &my_type_map, sizeof (my_type_map));
140 hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP); 140 hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP);
141 } 141 }
142 else 142 else
@@ -174,7 +174,7 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg)
174 return NULL; 174 return NULL;
175 } 175 }
176 ret = GNUNET_new (struct GSC_TypeMap); 176 ret = GNUNET_new (struct GSC_TypeMap);
177 memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap)); 177 GNUNET_memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap));
178 return ret; 178 return ret;
179 case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP: 179 case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP:
180 GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"), 180 GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"),
@@ -319,7 +319,7 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
319 319
320 ret = GNUNET_new (struct GSC_TypeMap); 320 ret = GNUNET_new (struct GSC_TypeMap);
321 if (NULL != tmap) 321 if (NULL != tmap)
322 memcpy (ret, tmap, sizeof (struct GSC_TypeMap)); 322 GNUNET_memcpy (ret, tmap, sizeof (struct GSC_TypeMap));
323 for (i = 0; i < tcnt; i++) 323 for (i = 0; i < tcnt; i++)
324 ret->bits[types[i] / 32] |= (1 << (types[i] % 32)); 324 ret->bits[types[i] / 32] |= (1 << (types[i] % 32));
325 return ret; 325 return ret;
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 94c223b74..10cef0e0d 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -194,7 +194,7 @@ transmit_ready (void *cls,
194 hdr.header.size = htons (s); 194 hdr.header.size = htons (s);
195 hdr.header.type = htons (MTYPE); 195 hdr.header.type = htons (MTYPE);
196 hdr.num = htonl (tr_n); 196 hdr.num = htonl (tr_n);
197 memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage)); 197 GNUNET_memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
198 ret += sizeof (struct TestMessage); 198 ret += sizeof (struct TestMessage);
199 memset (&cbuf[ret], tr_n, s - sizeof (struct TestMessage)); 199 memset (&cbuf[ret], tr_n, s - sizeof (struct TestMessage));
200 ret += s - sizeof (struct TestMessage); 200 ret += s - sizeof (struct TestMessage);
diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c
index 4889a038f..1387296da 100644
--- a/src/core/test_core_api_send_to_self.c
+++ b/src/core/test_core_api_send_to_self.c
@@ -133,7 +133,7 @@ init (void *cls,
133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
134 "Correctly connected to CORE; we are the peer %s.\n", 134 "Correctly connected to CORE; we are the peer %s.\n",
135 GNUNET_i2s (my_identity)); 135 GNUNET_i2s (my_identity));
136 memcpy (&myself, 136 GNUNET_memcpy (&myself,
137 my_identity, 137 my_identity,
138 sizeof (struct GNUNET_PeerIdentity)); 138 sizeof (struct GNUNET_PeerIdentity));
139} 139}
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index 28d836e2e..5e2db6fcb 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -334,7 +334,7 @@ transmit_ready (void *cls, size_t size, void *buf)
334 hdr.header.size = htons (MESSAGESIZE); 334 hdr.header.size = htons (MESSAGESIZE);
335 hdr.header.type = htons (MTYPE); 335 hdr.header.type = htons (MTYPE);
336 hdr.num = htonl (tr_n); 336 hdr.num = htonl (tr_n);
337 memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage)); 337 GNUNET_memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
338 ret += sizeof (struct TestMessage); 338 ret += sizeof (struct TestMessage);
339 memset (&cbuf[ret], tr_n, MESSAGESIZE - sizeof (struct TestMessage)); 339 memset (&cbuf[ret], tr_n, MESSAGESIZE - sizeof (struct TestMessage));
340 ret += MESSAGESIZE - sizeof (struct TestMessage); 340 ret += MESSAGESIZE - sizeof (struct TestMessage);
@@ -545,7 +545,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
545 "Received (my) `%s' from transport service\n", "HELLO"); 545 "Received (my) `%s' from transport service\n", "HELLO");
546 GNUNET_assert (message != NULL); 546 GNUNET_assert (message != NULL);
547 p->hello = GNUNET_malloc (ntohs (message->size)); 547 p->hello = GNUNET_malloc (ntohs (message->size));
548 memcpy (p->hello, message, ntohs (message->size)); 548 GNUNET_memcpy (p->hello, message, ntohs (message->size));
549 if ((p == &p1) && (p2.th != NULL)) 549 if ((p == &p1) && (p2.th != NULL))
550 GNUNET_TRANSPORT_offer_hello (p2.cfg, message, NULL, NULL); 550 GNUNET_TRANSPORT_offer_hello (p2.cfg, message, NULL, NULL);
551 if ((p == &p2) && (p1.th != NULL)) 551 if ((p == &p2) && (p1.th != NULL))