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/datastore | |
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/datastore')
-rw-r--r-- | src/datastore/datastore_api.c | 4 | ||||
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 8 | ||||
-rw-r--r-- | src/datastore/perf_plugin_datastore.c | 8 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_heap.c | 2 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 2 | ||||
-rw-r--r-- | src/datastore/test_datastore_api.c | 2 |
6 files changed, 13 insertions, 13 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index bf2f0097a..3f8ef9db4 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -974,7 +974,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
974 | dm->uid = GNUNET_htonll (0); | 974 | dm->uid = GNUNET_htonll (0); |
975 | dm->expiration = GNUNET_TIME_absolute_hton (expiration); | 975 | dm->expiration = GNUNET_TIME_absolute_hton (expiration); |
976 | dm->key = *key; | 976 | dm->key = *key; |
977 | memcpy (&dm[1], | 977 | GNUNET_memcpy (&dm[1], |
978 | data, | 978 | data, |
979 | size); | 979 | size); |
980 | qc.sc.cont = cont; | 980 | qc.sc.cont = cont; |
@@ -1248,7 +1248,7 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, | |||
1248 | dm->uid = GNUNET_htonll (0); | 1248 | dm->uid = GNUNET_htonll (0); |
1249 | dm->expiration = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_ZERO_ABS); | 1249 | dm->expiration = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_ZERO_ABS); |
1250 | dm->key = *key; | 1250 | dm->key = *key; |
1251 | memcpy (&dm[1], | 1251 | GNUNET_memcpy (&dm[1], |
1252 | data, | 1252 | data, |
1253 | size); | 1253 | size); |
1254 | 1254 | ||
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 620705ee2..5853d447d 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -526,7 +526,7 @@ transmit_callback (void *cls, size_t size, void *buf) | |||
526 | return 0; | 526 | return 0; |
527 | } | 527 | } |
528 | GNUNET_assert (size >= msize); | 528 | GNUNET_assert (size >= msize); |
529 | memcpy (buf, tcc->msg, msize); | 529 | GNUNET_memcpy (buf, tcc->msg, msize); |
530 | GNUNET_SERVER_receive_done (tcc->client, GNUNET_OK); | 530 | GNUNET_SERVER_receive_done (tcc->client, GNUNET_OK); |
531 | GNUNET_SERVER_client_drop (tcc->client); | 531 | GNUNET_SERVER_client_drop (tcc->client); |
532 | GNUNET_free (tcc->msg); | 532 | GNUNET_free (tcc->msg); |
@@ -598,7 +598,7 @@ transmit_status (struct GNUNET_SERVER_Client *client, int code, const char *msg) | |||
598 | sm->status = htonl (code); | 598 | sm->status = htonl (code); |
599 | sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration); | 599 | sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration); |
600 | if (slen > 0) | 600 | if (slen > 0) |
601 | memcpy (&sm[1], msg, slen); | 601 | GNUNET_memcpy (&sm[1], msg, slen); |
602 | transmit (client, &sm->header); | 602 | transmit (client, &sm->header); |
603 | } | 603 | } |
604 | 604 | ||
@@ -662,7 +662,7 @@ transmit_item (void *cls, | |||
662 | dm->expiration = GNUNET_TIME_absolute_hton (expiration); | 662 | dm->expiration = GNUNET_TIME_absolute_hton (expiration); |
663 | dm->uid = GNUNET_htonll (uid); | 663 | dm->uid = GNUNET_htonll (uid); |
664 | dm->key = *key; | 664 | dm->key = *key; |
665 | memcpy (&dm[1], data, size); | 665 | GNUNET_memcpy (&dm[1], data, size); |
666 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 666 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
667 | "Transmitting `%s' message for `%s' of type %u with expiration %s (in: %s)\n", | 667 | "Transmitting `%s' message for `%s' of type %u with expiration %s (in: %s)\n", |
668 | "DATA", GNUNET_h2s (key), type, | 668 | "DATA", GNUNET_h2s (key), type, |
@@ -1067,7 +1067,7 @@ handle_put (void *cls, | |||
1067 | sizeof (struct DataMessage)); | 1067 | sizeof (struct DataMessage)); |
1068 | pc->client = client; | 1068 | pc->client = client; |
1069 | GNUNET_SERVER_client_keep (client); | 1069 | GNUNET_SERVER_client_keep (client); |
1070 | memcpy (&pc[1], dm, size + sizeof (struct DataMessage)); | 1070 | GNUNET_memcpy (&pc[1], dm, size + sizeof (struct DataMessage)); |
1071 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (filter, &dm->key)) | 1071 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (filter, &dm->key)) |
1072 | { | 1072 | { |
1073 | GNUNET_CRYPTO_hash (&dm[1], size, &vhash); | 1073 | GNUNET_CRYPTO_hash (&dm[1], size, &vhash); |
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index cbc01844e..1e43b74b4 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c | |||
@@ -179,7 +179,7 @@ do_put (struct CpsRunContext *crc) | |||
179 | if (i > 255) | 179 | if (i > 255) |
180 | memset (value, i - 255, size / 2); | 180 | memset (value, i - 255, size / 2); |
181 | value[0] = crc->i; | 181 | value[0] = crc->i; |
182 | memcpy (&value[4], &i, sizeof (i)); | 182 | GNUNET_memcpy (&value[4], &i, sizeof (i)); |
183 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 183 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
184 | crc->api->put (crc->api->cls, &key, size, value, 1 + i % 4 /* type */ , | 184 | crc->api->put (crc->api->cls, &key, size, value, 1 + i % 4 /* type */ , |
185 | prio, i % 4 /* anonymity */ , | 185 | prio, i % 4 /* anonymity */ , |
@@ -212,7 +212,7 @@ iterate_zeros (void *cls, | |||
212 | 212 | ||
213 | GNUNET_assert (key != NULL); | 213 | GNUNET_assert (key != NULL); |
214 | GNUNET_assert (size >= 8); | 214 | GNUNET_assert (size >= 8); |
215 | memcpy (&i, &cdata[4], sizeof (i)); | 215 | GNUNET_memcpy (&i, &cdata[4], sizeof (i)); |
216 | hits[i / 8] |= (1 << (i % 8)); | 216 | hits[i / 8] |= (1 << (i % 8)); |
217 | 217 | ||
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -267,7 +267,7 @@ expiration_get (void *cls, | |||
267 | const char *cdata = data; | 267 | const char *cdata = data; |
268 | 268 | ||
269 | GNUNET_assert (size >= 8); | 269 | GNUNET_assert (size >= 8); |
270 | memcpy (&i, &cdata[4], sizeof (i)); | 270 | GNUNET_memcpy (&i, &cdata[4], sizeof (i)); |
271 | hits[i / 8] |= (1 << (i % 8)); | 271 | hits[i / 8] |= (1 << (i % 8)); |
272 | crc->cnt++; | 272 | crc->cnt++; |
273 | if (PUT_10 <= crc->cnt) | 273 | if (PUT_10 <= crc->cnt) |
@@ -320,7 +320,7 @@ replication_get (void *cls, | |||
320 | 320 | ||
321 | GNUNET_assert (NULL != key); | 321 | GNUNET_assert (NULL != key); |
322 | GNUNET_assert (size >= 8); | 322 | GNUNET_assert (size >= 8); |
323 | memcpy (&i, &cdata[4], sizeof (i)); | 323 | GNUNET_memcpy (&i, &cdata[4], sizeof (i)); |
324 | hits[i / 8] |= (1 << (i % 8)); | 324 | hits[i / 8] |= (1 << (i % 8)); |
325 | crc->cnt++; | 325 | crc->cnt++; |
326 | if (PUT_10 <= crc->cnt) | 326 | if (PUT_10 <= crc->cnt) |
diff --git a/src/datastore/plugin_datastore_heap.c b/src/datastore/plugin_datastore_heap.c index 0e7267aff..51f61764c 100644 --- a/src/datastore/plugin_datastore_heap.c +++ b/src/datastore/plugin_datastore_heap.c | |||
@@ -263,7 +263,7 @@ heap_plugin_put (void *cls, | |||
263 | value->anonymity = anonymity; | 263 | value->anonymity = anonymity; |
264 | value->replication = replication; | 264 | value->replication = replication; |
265 | value->type = type; | 265 | value->type = type; |
266 | memcpy (&value[1], data, size); | 266 | GNUNET_memcpy (&value[1], data, size); |
267 | GNUNET_CONTAINER_multihashmap_put (plugin->keyvalue, | 267 | GNUNET_CONTAINER_multihashmap_put (plugin->keyvalue, |
268 | &value->key, | 268 | &value->key, |
269 | value, | 269 | value, |
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index faf988517..332a8688b 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c | |||
@@ -946,7 +946,7 @@ postgres_plugin_get_keys (void *cls, | |||
946 | if (sizeof (struct GNUNET_HashCode) != | 946 | if (sizeof (struct GNUNET_HashCode) != |
947 | PQgetlength (res, i, 0)) | 947 | PQgetlength (res, i, 0)) |
948 | { | 948 | { |
949 | memcpy (&key, | 949 | GNUNET_memcpy (&key, |
950 | PQgetvalue (res, i, 0), | 950 | PQgetvalue (res, i, 0), |
951 | sizeof (struct GNUNET_HashCode)); | 951 | sizeof (struct GNUNET_HashCode)); |
952 | proc (proc_cls, &key, 1); | 952 | proc (proc_cls, &key, 1); |
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 6ebfee01e..43f6e9fa6 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c | |||
@@ -297,7 +297,7 @@ delete_value (void *cls, | |||
297 | crc->size = size; | 297 | crc->size = size; |
298 | crc->key = *key; | 298 | crc->key = *key; |
299 | crc->data = GNUNET_malloc (size); | 299 | crc->data = GNUNET_malloc (size); |
300 | memcpy (crc->data, data, size); | 300 | GNUNET_memcpy (crc->data, data, size); |
301 | crc->phase = RP_DO_DEL; | 301 | crc->phase = RP_DO_DEL; |
302 | GNUNET_SCHEDULER_add_now (&run_continuation, | 302 | GNUNET_SCHEDULER_add_now (&run_continuation, |
303 | crc); | 303 | crc); |