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/identity-provider | |
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/identity-provider')
-rw-r--r-- | src/identity-provider/gnunet-identity-token.c | 2 | ||||
-rw-r--r-- | src/identity-provider/gnunet-service-identity-provider.c | 16 | ||||
-rw-r--r-- | src/identity-provider/identity_provider_api.c | 6 | ||||
-rw-r--r-- | src/identity-provider/identity_token.c | 12 |
4 files changed, 18 insertions, 18 deletions
diff --git a/src/identity-provider/gnunet-identity-token.c b/src/identity-provider/gnunet-identity-token.c index 3d2830835..3e7d5bd9b 100644 --- a/src/identity-provider/gnunet-identity-token.c +++ b/src/identity-provider/gnunet-identity-token.c | |||
@@ -58,7 +58,7 @@ run (void *cls, | |||
58 | purpose = (struct GNUNET_CRYPTO_EccSignaturePurpose*)val; | 58 | purpose = (struct GNUNET_CRYPTO_EccSignaturePurpose*)val; |
59 | purpose->size = htonl(sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + strlen (data)); | 59 | purpose->size = htonl(sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + strlen (data)); |
60 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TOKEN); | 60 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TOKEN); |
61 | memcpy (&purpose[1], data, strlen(data)); | 61 | GNUNET_memcpy (&purpose[1], data, strlen(data)); |
62 | GNUNET_free (data); | 62 | GNUNET_free (data); |
63 | GNUNET_free (header_b64); | 63 | GNUNET_free (header_b64); |
64 | GNUNET_free (header_b64); | 64 | GNUNET_free (header_b64); |
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index 32a695091..7a68fe902 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c | |||
@@ -462,11 +462,11 @@ handle_token_update (void *cls) | |||
462 | + strlen (scopes) + 1; //With 0-Terminator | 462 | + strlen (scopes) + 1; //With 0-Terminator |
463 | token_metadata = GNUNET_malloc (token_metadata_len); | 463 | token_metadata = GNUNET_malloc (token_metadata_len); |
464 | write_ptr = token_metadata; | 464 | write_ptr = token_metadata; |
465 | memcpy (token_metadata, new_ecdhe_privkey, sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); | 465 | GNUNET_memcpy (token_metadata, new_ecdhe_privkey, sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); |
466 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey); | 466 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey); |
467 | memcpy (write_ptr, &token->aud_key, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 467 | GNUNET_memcpy (write_ptr, &token->aud_key, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
468 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); | 468 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); |
469 | memcpy (write_ptr, scopes, strlen (scopes) + 1); //with 0-Terminator; | 469 | GNUNET_memcpy (write_ptr, scopes, strlen (scopes) + 1); //with 0-Terminator; |
470 | 470 | ||
471 | token_record[1].data = token_metadata; | 471 | token_record[1].data = token_metadata; |
472 | token_record[1].data_size = token_metadata_len; | 472 | token_record[1].data_size = token_metadata_len; |
@@ -886,7 +886,7 @@ create_exchange_result_message (const char* token, | |||
886 | erm->header.size = htons (sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage) | 886 | erm->header.size = htons (sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage) |
887 | + token_len); | 887 | + token_len); |
888 | erm->ticket_nonce = htonl (ticket_nonce); | 888 | erm->ticket_nonce = htonl (ticket_nonce); |
889 | memcpy (&erm[1], token, token_len); | 889 | GNUNET_memcpy (&erm[1], token, token_len); |
890 | return erm; | 890 | return erm; |
891 | } | 891 | } |
892 | 892 | ||
@@ -909,7 +909,7 @@ create_issue_result_message (const char* label, | |||
909 | + strlen (ticket) + 1 | 909 | + strlen (ticket) + 1 |
910 | + strlen (token) + 1); | 910 | + strlen (token) + 1); |
911 | GNUNET_asprintf (&tmp_str, "%s,%s,%s", label, ticket, token); | 911 | GNUNET_asprintf (&tmp_str, "%s,%s,%s", label, ticket, token); |
912 | memcpy (&irm[1], tmp_str, strlen (tmp_str) + 1); | 912 | GNUNET_memcpy (&irm[1], tmp_str, strlen (tmp_str) + 1); |
913 | GNUNET_free (tmp_str); | 913 | GNUNET_free (tmp_str); |
914 | return irm; | 914 | return irm; |
915 | } | 915 | } |
@@ -1051,11 +1051,11 @@ sign_and_return_token (void *cls) | |||
1051 | + strlen (handle->scopes) + 1; //With 0-Terminator | 1051 | + strlen (handle->scopes) + 1; //With 0-Terminator |
1052 | token_metadata = GNUNET_malloc (token_metadata_len); | 1052 | token_metadata = GNUNET_malloc (token_metadata_len); |
1053 | write_ptr = token_metadata; | 1053 | write_ptr = token_metadata; |
1054 | memcpy (token_metadata, ecdhe_privkey, sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); | 1054 | GNUNET_memcpy (token_metadata, ecdhe_privkey, sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); |
1055 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey); | 1055 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey); |
1056 | memcpy (write_ptr, &handle->aud_key, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 1056 | GNUNET_memcpy (write_ptr, &handle->aud_key, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
1057 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); | 1057 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey); |
1058 | memcpy (write_ptr, handle->scopes, strlen (handle->scopes) + 1); //with 0-Terminator; | 1058 | GNUNET_memcpy (write_ptr, handle->scopes, strlen (handle->scopes) + 1); //with 0-Terminator; |
1059 | 1059 | ||
1060 | token_record[1].data = token_metadata; | 1060 | token_record[1].data = token_metadata; |
1061 | token_record[1].data_size = token_metadata_len; | 1061 | token_record[1].data_size = token_metadata_len; |
diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c index 53081ae05..d0413c748 100644 --- a/src/identity-provider/identity_provider_api.c +++ b/src/identity-provider/identity_provider_api.c | |||
@@ -346,7 +346,7 @@ send_next_message (void *cls, | |||
346 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 346 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
347 | "Sending message of type %d to identity provider service\n", | 347 | "Sending message of type %d to identity provider service\n", |
348 | ntohs (op->msg->type)); | 348 | ntohs (op->msg->type)); |
349 | memcpy (buf, op->msg, ret); | 349 | GNUNET_memcpy (buf, op->msg, ret); |
350 | if ( (NULL == op->iss_cb) && | 350 | if ( (NULL == op->iss_cb) && |
351 | (NULL == op->ex_cb) ) | 351 | (NULL == op->ex_cb) ) |
352 | { | 352 | { |
@@ -474,7 +474,7 @@ GNUNET_IDENTITY_PROVIDER_issue_token (struct GNUNET_IDENTITY_PROVIDER_Handle *id | |||
474 | im->aud_key = *aud_key; | 474 | im->aud_key = *aud_key; |
475 | im->nonce = htonl (nonce); | 475 | im->nonce = htonl (nonce); |
476 | im->expiration = GNUNET_TIME_absolute_hton (expiration); | 476 | im->expiration = GNUNET_TIME_absolute_hton (expiration); |
477 | memcpy (&im[1], scopes, slen); | 477 | GNUNET_memcpy (&im[1], scopes, slen); |
478 | op->msg = &im->header; | 478 | op->msg = &im->header; |
479 | GNUNET_CONTAINER_DLL_insert_tail (id->op_head, | 479 | GNUNET_CONTAINER_DLL_insert_tail (id->op_head, |
480 | id->op_tail, | 480 | id->op_tail, |
@@ -526,7 +526,7 @@ GNUNET_IDENTITY_PROVIDER_exchange_ticket (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
526 | em->header.size = htons (sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage) + | 526 | em->header.size = htons (sizeof (struct GNUNET_IDENTITY_PROVIDER_ExchangeMessage) + |
527 | slen); | 527 | slen); |
528 | em->aud_privkey = *aud_privkey; | 528 | em->aud_privkey = *aud_privkey; |
529 | memcpy (&em[1], ticket_str, slen); | 529 | GNUNET_memcpy (&em[1], ticket_str, slen); |
530 | GNUNET_free (ticket_str); | 530 | GNUNET_free (ticket_str); |
531 | op->msg = &em->header; | 531 | op->msg = &em->header; |
532 | GNUNET_CONTAINER_DLL_insert_tail (id->op_head, | 532 | GNUNET_CONTAINER_DLL_insert_tail (id->op_head, |
diff --git a/src/identity-provider/identity_token.c b/src/identity-provider/identity_token.c index 8f35170fb..dc94145d3 100644 --- a/src/identity-provider/identity_token.c +++ b/src/identity-provider/identity_token.c | |||
@@ -109,7 +109,7 @@ decrypt_str_ecdhe (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key, | |||
109 | return GNUNET_SYSERR; | 109 | return GNUNET_SYSERR; |
110 | } | 110 | } |
111 | *result_str = GNUNET_malloc (str_size+1); | 111 | *result_str = GNUNET_malloc (str_size+1); |
112 | memcpy (*result_str, str_buf, str_size); | 112 | GNUNET_memcpy (*result_str, str_buf, str_size); |
113 | (*result_str)[str_size] = '\0'; | 113 | (*result_str)[str_size] = '\0'; |
114 | GNUNET_free (str_buf); | 114 | GNUNET_free (str_buf); |
115 | return GNUNET_OK; | 115 | return GNUNET_OK; |
@@ -542,7 +542,7 @@ token_to_string (const struct IdentityToken *token, | |||
542 | purpose->size = | 542 | purpose->size = |
543 | htonl (strlen (signature_target) + sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); | 543 | htonl (strlen (signature_target) + sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); |
544 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TOKEN); | 544 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TOKEN); |
545 | memcpy (&purpose[1], signature_target, strlen (signature_target)); | 545 | GNUNET_memcpy (&purpose[1], signature_target, strlen (signature_target)); |
546 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (priv_key, | 546 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (priv_key, |
547 | purpose, | 547 | purpose, |
548 | (struct GNUNET_CRYPTO_EcdsaSignature *)&token->signature)) | 548 | (struct GNUNET_CRYPTO_EcdsaSignature *)&token->signature)) |
@@ -714,11 +714,11 @@ ticket_serialize (struct TokenTicket *ticket, | |||
714 | strlen (code_payload_str)); | 714 | strlen (code_payload_str)); |
715 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET); | 715 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET); |
716 | write_ptr = (char*) &purpose[1]; | 716 | write_ptr = (char*) &purpose[1]; |
717 | memcpy (write_ptr, | 717 | GNUNET_memcpy (write_ptr, |
718 | &ticket->ecdh_pubkey, | 718 | &ticket->ecdh_pubkey, |
719 | sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); | 719 | sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); |
720 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePublicKey); | 720 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePublicKey); |
721 | memcpy (write_ptr, enc_ticket_payload, strlen (code_payload_str)); | 721 | GNUNET_memcpy (write_ptr, enc_ticket_payload, strlen (code_payload_str)); |
722 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_ecdsa_sign (priv_key, | 722 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_ecdsa_sign (priv_key, |
723 | purpose, | 723 | purpose, |
724 | &ticket->signature)); | 724 | &ticket->signature)); |
@@ -932,9 +932,9 @@ ticket_parse (const char *raw_data, | |||
932 | enc_data_len); | 932 | enc_data_len); |
933 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET); | 933 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET); |
934 | write_ptr = (char*) &purpose[1]; | 934 | write_ptr = (char*) &purpose[1]; |
935 | memcpy (write_ptr, &ticket->ecdh_pubkey, sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); | 935 | GNUNET_memcpy (write_ptr, &ticket->ecdh_pubkey, sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); |
936 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePublicKey); | 936 | write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePublicKey); |
937 | memcpy (write_ptr, enc_data, enc_data_len); | 937 | GNUNET_memcpy (write_ptr, enc_data, enc_data_len); |
938 | 938 | ||
939 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET, | 939 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET, |
940 | purpose, | 940 | purpose, |