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/scalarproduct | |
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/scalarproduct')
5 files changed, 27 insertions, 27 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c index bf5ee1241..c9f4811e2 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c | |||
@@ -393,7 +393,7 @@ transmit_client_response (struct AliceServiceSession *s) | |||
393 | msg->product_length = htonl (product_length); | 393 | msg->product_length = htonl (product_length); |
394 | if (NULL != product_exported) | 394 | if (NULL != product_exported) |
395 | { | 395 | { |
396 | memcpy (&msg[1], | 396 | GNUNET_memcpy (&msg[1], |
397 | product_exported, | 397 | product_exported, |
398 | product_length); | 398 | product_length); |
399 | GNUNET_free (product_exported); | 399 | GNUNET_free (product_exported); |
@@ -949,7 +949,7 @@ GSS_handle_alice_client_message_multipart (void *cls, | |||
949 | for (i = 0; i < contained_count; i++) | 949 | for (i = 0; i < contained_count; i++) |
950 | { | 950 | { |
951 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 951 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
952 | memcpy (elem, | 952 | GNUNET_memcpy (elem, |
953 | &elements[i], | 953 | &elements[i], |
954 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 954 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
955 | if (GNUNET_SYSERR == | 955 | if (GNUNET_SYSERR == |
@@ -1052,7 +1052,7 @@ GSS_handle_alice_client_message (void *cls, | |||
1052 | if (0 == GNUNET_ntohll (elements[i].value)) | 1052 | if (0 == GNUNET_ntohll (elements[i].value)) |
1053 | continue; | 1053 | continue; |
1054 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 1054 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
1055 | memcpy (elem, | 1055 | GNUNET_memcpy (elem, |
1056 | &elements[i], | 1056 | &elements[i], |
1057 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 1057 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
1058 | if (GNUNET_SYSERR == | 1058 | if (GNUNET_SYSERR == |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c index a8dce9115..fbdf62192 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c | |||
@@ -966,7 +966,7 @@ GSS_handle_bob_client_message_multipart (void *cls, | |||
966 | for (i = 0; i < contained_count; i++) | 966 | for (i = 0; i < contained_count; i++) |
967 | { | 967 | { |
968 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 968 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
969 | memcpy (elem, | 969 | GNUNET_memcpy (elem, |
970 | &elements[i], | 970 | &elements[i], |
971 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 971 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
972 | if (GNUNET_SYSERR == | 972 | if (GNUNET_SYSERR == |
@@ -1091,7 +1091,7 @@ GSS_handle_bob_client_message (void *cls, | |||
1091 | if (0 == GNUNET_ntohll (elements[i].value)) | 1091 | if (0 == GNUNET_ntohll (elements[i].value)) |
1092 | continue; | 1092 | continue; |
1093 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 1093 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
1094 | memcpy (elem, | 1094 | GNUNET_memcpy (elem, |
1095 | &elements[i], | 1095 | &elements[i], |
1096 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 1096 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
1097 | if (GNUNET_SYSERR == | 1097 | if (GNUNET_SYSERR == |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index 76aee54e3..5478a85a7 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c | |||
@@ -413,7 +413,7 @@ transmit_client_response (struct AliceServiceSession *s) | |||
413 | msg->product_length = htonl (product_length); | 413 | msg->product_length = htonl (product_length); |
414 | if (NULL != product_exported) | 414 | if (NULL != product_exported) |
415 | { | 415 | { |
416 | memcpy (&msg[1], | 416 | GNUNET_memcpy (&msg[1], |
417 | product_exported, | 417 | product_exported, |
418 | product_length); | 418 | product_length); |
419 | GNUNET_free (product_exported); | 419 | GNUNET_free (product_exported); |
@@ -692,10 +692,10 @@ handle_bobs_cryptodata_multipart (void *cls, | |||
692 | /* Convert each k[][perm] to its MPI_value */ | 692 | /* Convert each k[][perm] to its MPI_value */ |
693 | for (i = 0; i < contained; i++) | 693 | for (i = 0; i < contained; i++) |
694 | { | 694 | { |
695 | memcpy (&s->r[s->cadet_received_element_count + i], | 695 | GNUNET_memcpy (&s->r[s->cadet_received_element_count + i], |
696 | &payload[2 * i], | 696 | &payload[2 * i], |
697 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 697 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
698 | memcpy (&s->r_prime[s->cadet_received_element_count + i], | 698 | GNUNET_memcpy (&s->r_prime[s->cadet_received_element_count + i], |
699 | &payload[2 * i], | 699 | &payload[2 * i], |
700 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 700 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
701 | } | 701 | } |
@@ -775,10 +775,10 @@ handle_bobs_cryptodata_message (void *cls, | |||
775 | (unsigned int) contained); | 775 | (unsigned int) contained); |
776 | 776 | ||
777 | payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; | 777 | payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; |
778 | memcpy (&s->s, | 778 | GNUNET_memcpy (&s->s, |
779 | &payload[0], | 779 | &payload[0], |
780 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 780 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
781 | memcpy (&s->s_prime, | 781 | GNUNET_memcpy (&s->s_prime, |
782 | &payload[1], | 782 | &payload[1], |
783 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 783 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
784 | payload = &payload[2]; | 784 | payload = &payload[2]; |
@@ -787,10 +787,10 @@ handle_bobs_cryptodata_message (void *cls, | |||
787 | s->r_prime = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * s->used_element_count); | 787 | s->r_prime = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * s->used_element_count); |
788 | for (i = 0; i < contained; i++) | 788 | for (i = 0; i < contained; i++) |
789 | { | 789 | { |
790 | memcpy (&s->r[i], | 790 | GNUNET_memcpy (&s->r[i], |
791 | &payload[2 * i], | 791 | &payload[2 * i], |
792 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 792 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
793 | memcpy (&s->r_prime[i], | 793 | GNUNET_memcpy (&s->r_prime[i], |
794 | &payload[2 * i + 1], | 794 | &payload[2 * i + 1], |
795 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 795 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
796 | } | 796 | } |
@@ -1173,7 +1173,7 @@ GSS_handle_alice_client_message_multipart (void *cls, | |||
1173 | for (i = 0; i < contained_count; i++) | 1173 | for (i = 0; i < contained_count; i++) |
1174 | { | 1174 | { |
1175 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 1175 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
1176 | memcpy (elem, | 1176 | GNUNET_memcpy (elem, |
1177 | &elements[i], | 1177 | &elements[i], |
1178 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 1178 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
1179 | if (GNUNET_SYSERR == | 1179 | if (GNUNET_SYSERR == |
@@ -1276,7 +1276,7 @@ GSS_handle_alice_client_message (void *cls, | |||
1276 | if (0 == GNUNET_ntohll (elements[i].value)) | 1276 | if (0 == GNUNET_ntohll (elements[i].value)) |
1277 | continue; | 1277 | continue; |
1278 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 1278 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
1279 | memcpy (elem, | 1279 | GNUNET_memcpy (elem, |
1280 | &elements[i], | 1280 | &elements[i], |
1281 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 1281 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
1282 | if (GNUNET_SYSERR == | 1282 | if (GNUNET_SYSERR == |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c index d0a622a36..5be0a85d1 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c | |||
@@ -570,10 +570,10 @@ transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s) | |||
570 | for (i = s->cadet_transmitted_element_count, j = 0; i < s->cadet_transmitted_element_count + todo_count; i++) | 570 | for (i = s->cadet_transmitted_element_count, j = 0; i < s->cadet_transmitted_element_count + todo_count; i++) |
571 | { | 571 | { |
572 | //r[i][p] and r[i][q] | 572 | //r[i][p] and r[i][q] |
573 | memcpy (&payload[j++], | 573 | GNUNET_memcpy (&payload[j++], |
574 | &s->r[i], | 574 | &s->r[i], |
575 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 575 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
576 | memcpy (&payload[j++], | 576 | GNUNET_memcpy (&payload[j++], |
577 | &s->r_prime[i], | 577 | &s->r_prime[i], |
578 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 578 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
579 | } | 579 | } |
@@ -627,10 +627,10 @@ transmit_bobs_cryptodata_message (struct BobServiceSession *s) | |||
627 | (unsigned int) s->used_element_count); | 627 | (unsigned int) s->used_element_count); |
628 | 628 | ||
629 | payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; | 629 | payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; |
630 | memcpy (&payload[0], | 630 | GNUNET_memcpy (&payload[0], |
631 | &s->s, | 631 | &s->s, |
632 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 632 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
633 | memcpy (&payload[1], | 633 | GNUNET_memcpy (&payload[1], |
634 | &s->s_prime, | 634 | &s->s_prime, |
635 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 635 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
636 | 636 | ||
@@ -639,10 +639,10 @@ transmit_bobs_cryptodata_message (struct BobServiceSession *s) | |||
639 | for (i = 0; i < s->cadet_transmitted_element_count; i++) | 639 | for (i = 0; i < s->cadet_transmitted_element_count; i++) |
640 | { | 640 | { |
641 | //k[i][p] and k[i][q] | 641 | //k[i][p] and k[i][q] |
642 | memcpy (&payload[i * 2], | 642 | GNUNET_memcpy (&payload[i * 2], |
643 | &s->r[i], | 643 | &s->r[i], |
644 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 644 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
645 | memcpy (&payload[i * 2 + 1], | 645 | GNUNET_memcpy (&payload[i * 2 + 1], |
646 | &s->r_prime[i], | 646 | &s->r_prime[i], |
647 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); | 647 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); |
648 | } | 648 | } |
@@ -991,7 +991,7 @@ handle_alices_cryptodata_message (void *cls, | |||
991 | if (NULL == s->e_a) | 991 | if (NULL == s->e_a) |
992 | s->e_a = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * | 992 | s->e_a = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * |
993 | max); | 993 | max); |
994 | memcpy (&s->e_a[s->cadet_received_element_count], | 994 | GNUNET_memcpy (&s->e_a[s->cadet_received_element_count], |
995 | payload, | 995 | payload, |
996 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * contained_elements); | 996 | sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * contained_elements); |
997 | s->cadet_received_element_count += contained_elements; | 997 | s->cadet_received_element_count += contained_elements; |
@@ -1262,7 +1262,7 @@ GSS_handle_bob_client_message_multipart (void *cls, | |||
1262 | for (i = 0; i < contained_count; i++) | 1262 | for (i = 0; i < contained_count; i++) |
1263 | { | 1263 | { |
1264 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 1264 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
1265 | memcpy (elem, | 1265 | GNUNET_memcpy (elem, |
1266 | &elements[i], | 1266 | &elements[i], |
1267 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 1267 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
1268 | if (GNUNET_SYSERR == | 1268 | if (GNUNET_SYSERR == |
@@ -1387,7 +1387,7 @@ GSS_handle_bob_client_message (void *cls, | |||
1387 | if (0 == GNUNET_ntohll (elements[i].value)) | 1387 | if (0 == GNUNET_ntohll (elements[i].value)) |
1388 | continue; | 1388 | continue; |
1389 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 1389 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
1390 | memcpy (elem, | 1390 | GNUNET_memcpy (elem, |
1391 | &elements[i], | 1391 | &elements[i], |
1392 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 1392 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
1393 | if (GNUNET_SYSERR == | 1393 | if (GNUNET_SYSERR == |
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c index 8639b4e5a..09e06d5a0 100644 --- a/src/scalarproduct/scalarproduct_api.c +++ b/src/scalarproduct/scalarproduct_api.c | |||
@@ -279,7 +279,7 @@ GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handl | |||
279 | msg->element_count_total = htonl (element_count); | 279 | msg->element_count_total = htonl (element_count); |
280 | msg->element_count_contained = htonl (todo); | 280 | msg->element_count_contained = htonl (todo); |
281 | msg->session_key = *session_key; | 281 | msg->session_key = *session_key; |
282 | memcpy (&msg[1], | 282 | GNUNET_memcpy (&msg[1], |
283 | elements, | 283 | elements, |
284 | size); | 284 | size); |
285 | element_count_transfered = todo; | 285 | element_count_transfered = todo; |
@@ -296,7 +296,7 @@ GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handl | |||
296 | size, | 296 | size, |
297 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_BOB); | 297 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_BOB); |
298 | mmsg->element_count_contained = htonl (todo); | 298 | mmsg->element_count_contained = htonl (todo); |
299 | memcpy (&mmsg[1], | 299 | GNUNET_memcpy (&mmsg[1], |
300 | &elements[element_count_transfered], | 300 | &elements[element_count_transfered], |
301 | size); | 301 | size); |
302 | element_count_transfered += todo; | 302 | element_count_transfered += todo; |
@@ -439,7 +439,7 @@ GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle | |||
439 | msg->reserved = htonl (0); | 439 | msg->reserved = htonl (0); |
440 | msg->peer = *peer; | 440 | msg->peer = *peer; |
441 | msg->session_key = *session_key; | 441 | msg->session_key = *session_key; |
442 | memcpy (&msg[1], | 442 | GNUNET_memcpy (&msg[1], |
443 | elements, | 443 | elements, |
444 | size); | 444 | size); |
445 | GNUNET_MQ_send (h->mq, | 445 | GNUNET_MQ_send (h->mq, |
@@ -456,7 +456,7 @@ GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle | |||
456 | size, | 456 | size, |
457 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_ALICE); | 457 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_ALICE); |
458 | mmsg->element_count_contained = htonl (todo); | 458 | mmsg->element_count_contained = htonl (todo); |
459 | memcpy (&mmsg[1], | 459 | GNUNET_memcpy (&mmsg[1], |
460 | &elements[element_count_transfered], | 460 | &elements[element_count_transfered], |
461 | size); | 461 | size); |
462 | element_count_transfered += todo; | 462 | element_count_transfered += todo; |