aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_clients.c
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/dht/gnunet-service-dht_clients.c
parent5184c17d32a39c928c2a0fec3ee1ad098bbaa562 (diff)
downloadgnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.tar.gz
gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.zip
-avoid calling memcpy() with NULL argument, even if len is 0
Diffstat (limited to 'src/dht/gnunet-service-dht_clients.c')
-rw-r--r--src/dht/gnunet-service-dht_clients.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index b508df68a..2e8d309db 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -61,7 +61,7 @@ struct PendingMessage
61 /** 61 /**
62 * Actual message to be sent, allocated at the end of the struct: 62 * Actual message to be sent, allocated at the end of the struct:
63 * // msg = (cast) &pm[1]; 63 * // msg = (cast) &pm[1];
64 * // memcpy (&pm[1], data, len); 64 * // GNUNET_memcpy (&pm[1], data, len);
65 */ 65 */
66 const struct GNUNET_MessageHeader *msg; 66 const struct GNUNET_MessageHeader *msg;
67 67
@@ -604,7 +604,7 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client,
604 cqr->key = get->key; 604 cqr->key = get->key;
605 cqr->client = find_active_client (client); 605 cqr->client = find_active_client (client);
606 cqr->xquery = (void *) &cqr[1]; 606 cqr->xquery = (void *) &cqr[1];
607 memcpy (&cqr[1], xquery, xquery_size); 607 GNUNET_memcpy (&cqr[1], xquery, xquery_size);
608 cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, 0); 608 cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, 0);
609 cqr->retry_frequency = GNUNET_TIME_UNIT_SECONDS; 609 cqr->retry_frequency = GNUNET_TIME_UNIT_SECONDS;
610 cqr->retry_time = GNUNET_TIME_absolute_get (); 610 cqr->retry_time = GNUNET_TIME_absolute_get ();
@@ -725,7 +725,7 @@ handle_dht_local_get_result_seen (void *cls, struct GNUNET_SERVER_Client *client
725 GNUNET_array_grow (cqr->seen_replies, 725 GNUNET_array_grow (cqr->seen_replies,
726 cqr->seen_replies_count, 726 cqr->seen_replies_count,
727 cqr->seen_replies_count + hash_count); 727 cqr->seen_replies_count + hash_count);
728 memcpy (&cqr->seen_replies[old_count], 728 GNUNET_memcpy (&cqr->seen_replies[old_count],
729 hc, 729 hc,
730 sizeof (struct GNUNET_HashCode) * hash_count); 730 sizeof (struct GNUNET_HashCode) * hash_count);
731} 731}
@@ -834,7 +834,7 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
834 else 834 else
835 { 835 {
836 r->key = GNUNET_new (struct GNUNET_HashCode); 836 r->key = GNUNET_new (struct GNUNET_HashCode);
837 memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode)); 837 GNUNET_memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode));
838 } 838 }
839 GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r); 839 GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r);
840 GNUNET_SERVER_receive_done (client, GNUNET_OK); 840 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -926,7 +926,7 @@ send_reply_to_client (void *cls, size_t size, void *buf)
926 { 926 {
927 GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail, 927 GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail,
928 reply); 928 reply);
929 memcpy (&cbuf[off], reply->msg, msize); 929 GNUNET_memcpy (&cbuf[off], reply->msg, msize);
930 GNUNET_free (reply); 930 GNUNET_free (reply);
931 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 931 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
932 "Transmitting %u bytes to client %p\n", 932 "Transmitting %u bytes to client %p\n",
@@ -1117,7 +1117,7 @@ forward_reply (void *cls,
1117 /* two clients waiting for same reply, must copy for queueing */ 1117 /* two clients waiting for same reply, must copy for queueing */
1118 pm = GNUNET_malloc (sizeof (struct PendingMessage) + 1118 pm = GNUNET_malloc (sizeof (struct PendingMessage) +
1119 ntohs (frc->pm->msg->size)); 1119 ntohs (frc->pm->msg->size));
1120 memcpy (pm, frc->pm, 1120 GNUNET_memcpy (pm, frc->pm,
1121 sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size)); 1121 sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size));
1122 pm->next = pm->prev = NULL; 1122 pm->next = pm->prev = NULL;
1123 pm->msg = (struct GNUNET_MessageHeader *) &pm[1]; 1123 pm->msg = (struct GNUNET_MessageHeader *) &pm[1];
@@ -1204,11 +1204,11 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
1204 reply->expiration = GNUNET_TIME_absolute_hton (expiration); 1204 reply->expiration = GNUNET_TIME_absolute_hton (expiration);
1205 reply->key = *key; 1205 reply->key = *key;
1206 paths = (struct GNUNET_PeerIdentity *) &reply[1]; 1206 paths = (struct GNUNET_PeerIdentity *) &reply[1];
1207 memcpy (paths, put_path, 1207 GNUNET_memcpy (paths, put_path,
1208 sizeof (struct GNUNET_PeerIdentity) * put_path_length); 1208 sizeof (struct GNUNET_PeerIdentity) * put_path_length);
1209 memcpy (&paths[put_path_length], get_path, 1209 GNUNET_memcpy (&paths[put_path_length], get_path,
1210 sizeof (struct GNUNET_PeerIdentity) * get_path_length); 1210 sizeof (struct GNUNET_PeerIdentity) * get_path_length);
1211 memcpy (&paths[get_path_length + put_path_length], data, data_size); 1211 GNUNET_memcpy (&paths[get_path_length + put_path_length], data, data_size);
1212 frc.do_copy = GNUNET_NO; 1212 frc.do_copy = GNUNET_NO;
1213 frc.pm = pm; 1213 frc.pm = pm;
1214 frc.data = data; 1214 frc.data = data;
@@ -1291,10 +1291,10 @@ GDS_CLIENTS_process_get (uint32_t options,
1291 mmsg->hop_count = htonl(hop_count); 1291 mmsg->hop_count = htonl(hop_count);
1292 mmsg->desired_replication_level = htonl(desired_replication_level); 1292 mmsg->desired_replication_level = htonl(desired_replication_level);
1293 mmsg->get_path_length = htonl(path_length); 1293 mmsg->get_path_length = htonl(path_length);
1294 memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode)); 1294 GNUNET_memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
1295 msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1]; 1295 msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1296 if (path_length > 0) 1296 if (path_length > 0)
1297 memcpy (msg_path, path, 1297 GNUNET_memcpy (msg_path, path,
1298 path_length * sizeof (struct GNUNET_PeerIdentity)); 1298 path_length * sizeof (struct GNUNET_PeerIdentity));
1299 add_pending_message (m->client, pm); 1299 add_pending_message (m->client, pm);
1300 } 1300 }
@@ -1370,17 +1370,17 @@ GDS_CLIENTS_process_get_resp (enum GNUNET_BLOCK_Type type,
1370 path = (struct GNUNET_PeerIdentity *) &mmsg[1]; 1370 path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1371 if (put_path_length > 0) 1371 if (put_path_length > 0)
1372 { 1372 {
1373 memcpy (path, put_path, 1373 GNUNET_memcpy (path, put_path,
1374 put_path_length * sizeof (struct GNUNET_PeerIdentity)); 1374 put_path_length * sizeof (struct GNUNET_PeerIdentity));
1375 path = &path[put_path_length]; 1375 path = &path[put_path_length];
1376 } 1376 }
1377 if (get_path_length > 0) 1377 if (get_path_length > 0)
1378 memcpy (path, get_path, 1378 GNUNET_memcpy (path, get_path,
1379 get_path_length * sizeof (struct GNUNET_PeerIdentity)); 1379 get_path_length * sizeof (struct GNUNET_PeerIdentity));
1380 mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp); 1380 mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp);
1381 memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode)); 1381 GNUNET_memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
1382 if (size > 0) 1382 if (size > 0)
1383 memcpy (&path[get_path_length], data, size); 1383 GNUNET_memcpy (&path[get_path_length], data, size);
1384 add_pending_message (m->client, pm); 1384 add_pending_message (m->client, pm);
1385 } 1385 }
1386 } 1386 }
@@ -1458,14 +1458,14 @@ GDS_CLIENTS_process_put (uint32_t options,
1458 msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1]; 1458 msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
1459 if (path_length > 0) 1459 if (path_length > 0)
1460 { 1460 {
1461 memcpy (msg_path, 1461 GNUNET_memcpy (msg_path,
1462 path, 1462 path,
1463 path_length * sizeof (struct GNUNET_PeerIdentity)); 1463 path_length * sizeof (struct GNUNET_PeerIdentity));
1464 } 1464 }
1465 mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp); 1465 mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp);
1466 memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode)); 1466 GNUNET_memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
1467 if (size > 0) 1467 if (size > 0)
1468 memcpy (&msg_path[path_length], data, size); 1468 GNUNET_memcpy (&msg_path[path_length], data, size);
1469 add_pending_message (m->client, pm); 1469 add_pending_message (m->client, pm);
1470 } 1470 }
1471 } 1471 }