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/hello | |
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/hello')
-rw-r--r-- | src/hello/address.c | 4 | ||||
-rw-r--r-- | src/hello/hello.c | 22 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/hello/address.c b/src/hello/address.c index 5d26b1109..7819c2806 100644 --- a/src/hello/address.c +++ b/src/hello/address.c | |||
@@ -89,10 +89,10 @@ GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | |||
89 | addr->local_info = local_info; | 89 | addr->local_info = local_info; |
90 | end = (char *) &addr[1]; | 90 | end = (char *) &addr[1]; |
91 | addr->transport_name = &end[address_length]; | 91 | addr->transport_name = &end[address_length]; |
92 | memcpy (end, | 92 | GNUNET_memcpy (end, |
93 | address, | 93 | address, |
94 | address_length); | 94 | address_length); |
95 | memcpy (&end[address_length], | 95 | GNUNET_memcpy (&end[address_length], |
96 | transport_name, | 96 | transport_name, |
97 | slen); | 97 | slen); |
98 | return addr; | 98 | return addr; |
diff --git a/src/hello/hello.c b/src/hello/hello.c index 5d0c7111b..b200846f5 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c | |||
@@ -157,12 +157,12 @@ GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, | |||
157 | return 0; | 157 | return 0; |
158 | exp = GNUNET_TIME_absolute_hton (expiration); | 158 | exp = GNUNET_TIME_absolute_hton (expiration); |
159 | alen = htons ((uint16_t) address->address_length); | 159 | alen = htons ((uint16_t) address->address_length); |
160 | memcpy (target, address->transport_name, slen); | 160 | GNUNET_memcpy (target, address->transport_name, slen); |
161 | memcpy (&target[slen], &alen, sizeof (uint16_t)); | 161 | GNUNET_memcpy (&target[slen], &alen, sizeof (uint16_t)); |
162 | slen += sizeof (uint16_t); | 162 | slen += sizeof (uint16_t); |
163 | memcpy (&target[slen], &exp, sizeof (struct GNUNET_TIME_AbsoluteNBO)); | 163 | GNUNET_memcpy (&target[slen], &exp, sizeof (struct GNUNET_TIME_AbsoluteNBO)); |
164 | slen += sizeof (struct GNUNET_TIME_AbsoluteNBO); | 164 | slen += sizeof (struct GNUNET_TIME_AbsoluteNBO); |
165 | memcpy (&target[slen], address->address, address->address_length); | 165 | GNUNET_memcpy (&target[slen], address->address, address->address_length); |
166 | slen += address->address_length; | 166 | slen += address->address_length; |
167 | return slen; | 167 | return slen; |
168 | } | 168 | } |
@@ -208,7 +208,7 @@ get_hello_address_size (const char *buf, | |||
208 | GNUNET_break_op (0); | 208 | GNUNET_break_op (0); |
209 | return 0; | 209 | return 0; |
210 | } | 210 | } |
211 | memcpy (&alen, pos, sizeof (uint16_t)); | 211 | GNUNET_memcpy (&alen, pos, sizeof (uint16_t)); |
212 | alen = ntohs (alen); | 212 | alen = ntohs (alen); |
213 | *ralen = alen; | 213 | *ralen = alen; |
214 | slen += alen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO); | 214 | slen += alen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO); |
@@ -269,7 +269,7 @@ GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | |||
269 | hello->header.size = htons (sizeof (struct GNUNET_HELLO_Message) + used); | 269 | hello->header.size = htons (sizeof (struct GNUNET_HELLO_Message) + used); |
270 | hello->friend_only = htonl (friend_only); | 270 | hello->friend_only = htonl (friend_only); |
271 | hello->publicKey = *public_key; | 271 | hello->publicKey = *public_key; |
272 | memcpy (&hello[1], | 272 | GNUNET_memcpy (&hello[1], |
273 | buffer, | 273 | buffer, |
274 | used); | 274 | used); |
275 | return hello; | 275 | return hello; |
@@ -312,7 +312,7 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
312 | if (return_modified) | 312 | if (return_modified) |
313 | { | 313 | { |
314 | ret = GNUNET_malloc (msize); | 314 | ret = GNUNET_malloc (msize); |
315 | memcpy (ret, | 315 | GNUNET_memcpy (ret, |
316 | msg, | 316 | msg, |
317 | msize); | 317 | msize); |
318 | } | 318 | } |
@@ -332,8 +332,8 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
332 | GNUNET_free_non_null (ret); | 332 | GNUNET_free_non_null (ret); |
333 | return NULL; | 333 | return NULL; |
334 | } | 334 | } |
335 | /* need memcpy() due to possibility of misalignment */ | 335 | /* need GNUNET_memcpy() due to possibility of misalignment */ |
336 | memcpy (&expire, | 336 | GNUNET_memcpy (&expire, |
337 | &inptr[esize - alen - sizeof (struct GNUNET_TIME_AbsoluteNBO)], | 337 | &inptr[esize - alen - sizeof (struct GNUNET_TIME_AbsoluteNBO)], |
338 | sizeof (struct GNUNET_TIME_AbsoluteNBO)); | 338 | sizeof (struct GNUNET_TIME_AbsoluteNBO)); |
339 | address.address = &inptr[esize - alen]; | 339 | address.address = &inptr[esize - alen]; |
@@ -349,7 +349,7 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
349 | (NULL != ret) ) | 349 | (NULL != ret) ) |
350 | { | 350 | { |
351 | /* copy address over */ | 351 | /* copy address over */ |
352 | memcpy (woff, | 352 | GNUNET_memcpy (woff, |
353 | inptr, | 353 | inptr, |
354 | esize); | 354 | esize); |
355 | woff += esize; | 355 | woff += esize; |
@@ -1021,7 +1021,7 @@ add_address_to_uri (void *cls, | |||
1021 | 1021 | ||
1022 | addr_dup = GNUNET_strdup (addr); | 1022 | addr_dup = GNUNET_strdup (addr); |
1023 | if (NULL != (pos = strstr (addr_dup, "_server"))) | 1023 | if (NULL != (pos = strstr (addr_dup, "_server"))) |
1024 | memcpy (pos, | 1024 | GNUNET_memcpy (pos, |
1025 | client_str, | 1025 | client_str, |
1026 | strlen (client_str)); /* Replace all server addresses with client addresses */ | 1026 | strlen (client_str)); /* Replace all server addresses with client addresses */ |
1027 | 1027 | ||