aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
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/vpn
parent5184c17d32a39c928c2a0fec3ee1ad098bbaa562 (diff)
downloadgnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.tar.gz
gnunet-d8c53b12a818ff7cf82d06a1a69c395bdef85ee6.zip
-avoid calling memcpy() with NULL argument, even if len is 0
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c12
-rw-r--r--src/vpn/gnunet-service-vpn.c46
-rw-r--r--src/vpn/vpn_api.c4
3 files changed, 31 insertions, 31 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c
index 94af0e8e8..a9596752a 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -922,7 +922,7 @@ attempt_read_tap (struct io_facility * input_facility,
922 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; 922 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer;
923 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); 923 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader);
924 924
925 memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader), 925 GNUNET_memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader),
926 input_facility->buffer, 926 input_facility->buffer,
927 input_facility->buffer_size); 927 input_facility->buffer_size);
928 928
@@ -978,7 +978,7 @@ attempt_read_tap (struct io_facility * input_facility,
978 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; 978 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer;
979 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); 979 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader);
980 980
981 memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader), 981 GNUNET_memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader),
982 input_facility->buffer, 982 input_facility->buffer,
983 input_facility->buffer_size); 983 input_facility->buffer_size);
984 984
@@ -1012,7 +1012,7 @@ attempt_read_tap (struct io_facility * input_facility,
1012 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer; 1012 hdr = (struct GNUNET_MessageHeader *) output_facility->buffer;
1013 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader); 1013 size = input_facility->buffer_size + sizeof (struct GNUNET_MessageHeader);
1014 1014
1015 memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader), 1015 GNUNET_memcpy (output_facility->buffer + sizeof (struct GNUNET_MessageHeader),
1016 input_facility->buffer, 1016 input_facility->buffer,
1017 input_facility->buffer_size); 1017 input_facility->buffer_size);
1018 1018
@@ -1105,7 +1105,7 @@ partial_read_iostate_ready:
1105 * send it our via STDOUT. Is that possible at the moment? */ 1105 * send it our via STDOUT. Is that possible at the moment? */
1106 1106
1107 /* hand over this buffers content and strip gnunet message header */ 1107 /* hand over this buffers content and strip gnunet message header */
1108 memcpy (output_facility->buffer, 1108 GNUNET_memcpy (output_facility->buffer,
1109 input_facility->buffer + sizeof (struct GNUNET_MessageHeader), 1109 input_facility->buffer + sizeof (struct GNUNET_MessageHeader),
1110 input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader)); 1110 input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader));
1111 output_facility->buffer_size = input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader); 1111 output_facility->buffer_size = input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader);
@@ -1169,7 +1169,7 @@ partial_read_iostate_ready:
1169 IOSTATE_WAITING == output_facility->facility_state) 1169 IOSTATE_WAITING == output_facility->facility_state)
1170 && input_facility->buffer_size > sizeof(struct GNUNET_MessageHeader)) 1170 && input_facility->buffer_size > sizeof(struct GNUNET_MessageHeader))
1171 { /* hand over this buffers content and strip gnunet message header */ 1171 { /* hand over this buffers content and strip gnunet message header */
1172 memcpy (output_facility->buffer, 1172 GNUNET_memcpy (output_facility->buffer,
1173 input_facility->buffer + sizeof(struct GNUNET_MessageHeader), 1173 input_facility->buffer + sizeof(struct GNUNET_MessageHeader),
1174 input_facility->buffer_size - sizeof(struct GNUNET_MessageHeader)); 1174 input_facility->buffer_size - sizeof(struct GNUNET_MessageHeader));
1175 output_facility->buffer_size = input_facility->buffer_size - sizeof(struct GNUNET_MessageHeader); 1175 output_facility->buffer_size = input_facility->buffer_size - sizeof(struct GNUNET_MessageHeader);
@@ -1196,7 +1196,7 @@ partial_read_iostate_ready:
1196 } 1196 }
1197 return TRUE; 1197 return TRUE;
1198 case IOSTATE_RESUME: /* Our buffer was filled already but our write facility was busy. */ 1198 case IOSTATE_RESUME: /* Our buffer was filled already but our write facility was busy. */
1199 memcpy (output_facility->buffer, 1199 GNUNET_memcpy (output_facility->buffer,
1200 input_facility->buffer + sizeof (struct GNUNET_MessageHeader), 1200 input_facility->buffer + sizeof (struct GNUNET_MessageHeader),
1201 input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader)); 1201 input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader));
1202 output_facility->buffer_size = input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader); 1202 output_facility->buffer_size = input_facility->buffer_size - sizeof (struct GNUNET_MessageHeader);
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 8741aa719..ae7cb57cc 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -453,29 +453,29 @@ get_channel_key_from_ips (int af,
453 /* the GNUnet hashmap only uses the first sizeof(unsigned int) of the hash, 453 /* the GNUnet hashmap only uses the first sizeof(unsigned int) of the hash,
454 so we put the ports in there (and hope for few collisions) */ 454 so we put the ports in there (and hope for few collisions) */
455 off = (char*) key; 455 off = (char*) key;
456 memcpy (off, &source_port, sizeof (uint16_t)); 456 GNUNET_memcpy (off, &source_port, sizeof (uint16_t));
457 off += sizeof (uint16_t); 457 off += sizeof (uint16_t);
458 memcpy (off, &destination_port, sizeof (uint16_t)); 458 GNUNET_memcpy (off, &destination_port, sizeof (uint16_t));
459 off += sizeof (uint16_t); 459 off += sizeof (uint16_t);
460 switch (af) 460 switch (af)
461 { 461 {
462 case AF_INET: 462 case AF_INET:
463 memcpy (off, source_ip, sizeof (struct in_addr)); 463 GNUNET_memcpy (off, source_ip, sizeof (struct in_addr));
464 off += sizeof (struct in_addr); 464 off += sizeof (struct in_addr);
465 memcpy (off, destination_ip, sizeof (struct in_addr)); 465 GNUNET_memcpy (off, destination_ip, sizeof (struct in_addr));
466 off += sizeof (struct in_addr); 466 off += sizeof (struct in_addr);
467 break; 467 break;
468 case AF_INET6: 468 case AF_INET6:
469 memcpy (off, source_ip, sizeof (struct in6_addr)); 469 GNUNET_memcpy (off, source_ip, sizeof (struct in6_addr));
470 off += sizeof (struct in6_addr); 470 off += sizeof (struct in6_addr);
471 memcpy (off, destination_ip, sizeof (struct in6_addr)); 471 GNUNET_memcpy (off, destination_ip, sizeof (struct in6_addr));
472 off += sizeof (struct in6_addr); 472 off += sizeof (struct in6_addr);
473 break; 473 break;
474 default: 474 default:
475 GNUNET_assert (0); 475 GNUNET_assert (0);
476 break; 476 break;
477 } 477 }
478 memcpy (off, &protocol, sizeof (uint8_t)); 478 GNUNET_memcpy (off, &protocol, sizeof (uint8_t));
479 /* off += sizeof (uint8_t); */ 479 /* off += sizeof (uint8_t); */
480} 480}
481 481
@@ -518,7 +518,7 @@ send_client_reply (struct GNUNET_SERVER_Client *client,
518 res->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP); 518 res->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP);
519 res->result_af = htonl (result_af); 519 res->result_af = htonl (result_af);
520 res->request_id = request_id; 520 res->request_id = request_id;
521 memcpy (&res[1], addr, rlen); 521 GNUNET_memcpy (&res[1], addr, rlen);
522 GNUNET_SERVER_notification_context_add (nc, client); 522 GNUNET_SERVER_notification_context_add (nc, client);
523 GNUNET_SERVER_notification_context_unicast (nc, 523 GNUNET_SERVER_notification_context_unicast (nc,
524 client, 524 client,
@@ -618,7 +618,7 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
618 ts->tmq_tail, 618 ts->tmq_tail,
619 tnq); 619 tnq);
620 ts->tmq_length--; 620 ts->tmq_length--;
621 memcpy (buf, tnq->msg, tnq->len); 621 GNUNET_memcpy (buf, tnq->msg, tnq->len);
622 ret = tnq->len; 622 ret = tnq->len;
623 GNUNET_free (tnq); 623 GNUNET_free (tnq);
624 if (NULL != (tnq = ts->tmq_head)) 624 if (NULL != (tnq = ts->tmq_head))
@@ -1162,7 +1162,7 @@ route_packet (struct DestinationEntry *destination,
1162 usm->source_port = (ntohs (udp->source_port) < 32000) ? udp->source_port : 0; 1162 usm->source_port = (ntohs (udp->source_port) < 32000) ? udp->source_port : 0;
1163 usm->destination_port = udp->destination_port; 1163 usm->destination_port = udp->destination_port;
1164 usm->service_descriptor = destination->details.service_destination.service_descriptor; 1164 usm->service_descriptor = destination->details.service_destination.service_descriptor;
1165 memcpy (&usm[1], 1165 GNUNET_memcpy (&usm[1],
1166 &udp[1], 1166 &udp[1],
1167 payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); 1167 payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
1168 } 1168 }
@@ -1204,7 +1204,7 @@ route_packet (struct DestinationEntry *destination,
1204 default: 1204 default:
1205 GNUNET_assert (0); 1205 GNUNET_assert (0);
1206 } 1206 }
1207 memcpy (payload, 1207 GNUNET_memcpy (payload,
1208 &udp[1], 1208 &udp[1],
1209 payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); 1209 payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
1210 } 1210 }
@@ -1232,7 +1232,7 @@ route_packet (struct DestinationEntry *destination,
1232 tsm->reserved = htonl (0); 1232 tsm->reserved = htonl (0);
1233 tsm->service_descriptor = destination->details.service_destination.service_descriptor; 1233 tsm->service_descriptor = destination->details.service_destination.service_descriptor;
1234 tsm->tcp_header = *tcp; 1234 tsm->tcp_header = *tcp;
1235 memcpy (&tsm[1], 1235 GNUNET_memcpy (&tsm[1],
1236 &tcp[1], 1236 &tcp[1],
1237 payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); 1237 payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
1238 } 1238 }
@@ -1273,7 +1273,7 @@ route_packet (struct DestinationEntry *destination,
1273 default: 1273 default:
1274 GNUNET_assert (0); 1274 GNUNET_assert (0);
1275 } 1275 }
1276 memcpy (payload, 1276 GNUNET_memcpy (payload,
1277 &tcp[1], 1277 &tcp[1],
1278 payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); 1278 payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
1279 } 1279 }
@@ -1297,7 +1297,7 @@ route_packet (struct DestinationEntry *destination,
1297 tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT); 1297 tdm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT);
1298 tdm->reserved = htonl (0); 1298 tdm->reserved = htonl (0);
1299 tdm->tcp_header = *tcp; 1299 tdm->tcp_header = *tcp;
1300 memcpy (&tdm[1], 1300 GNUNET_memcpy (&tdm[1],
1301 &tcp[1], 1301 &tcp[1],
1302 payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); 1302 payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
1303 } 1303 }
@@ -1379,7 +1379,7 @@ route_packet (struct DestinationEntry *destination,
1379 tnq->len = mlen; 1379 tnq->len = mlen;
1380 ism->header.size = htons ((uint16_t) mlen); 1380 ism->header.size = htons ((uint16_t) mlen);
1381 /* finally, copy payload (if there is any left...) */ 1381 /* finally, copy payload (if there is any left...) */
1382 memcpy (&ism[1], 1382 GNUNET_memcpy (&ism[1],
1383 &icmp[1], 1383 &icmp[1],
1384 payload_length - sizeof (struct GNUNET_TUN_IcmpHeader)); 1384 payload_length - sizeof (struct GNUNET_TUN_IcmpHeader));
1385 } 1385 }
@@ -1532,7 +1532,7 @@ route_packet (struct DestinationEntry *destination,
1532 default: 1532 default:
1533 GNUNET_assert (0); 1533 GNUNET_assert (0);
1534 } 1534 }
1535 memcpy (payload, 1535 GNUNET_memcpy (payload,
1536 &icmp[1], 1536 &icmp[1],
1537 payload_length - sizeof (struct GNUNET_TUN_IcmpHeader)); 1537 payload_length - sizeof (struct GNUNET_TUN_IcmpHeader));
1538 } 1538 }
@@ -1799,7 +1799,7 @@ receive_icmp_back (void *cls,
1799 &ts->destination_ip.v4, 1799 &ts->destination_ip.v4,
1800 &ts->source_ip.v4); 1800 &ts->source_ip.v4);
1801 *icmp = i2v->icmp_header; 1801 *icmp = i2v->icmp_header;
1802 memcpy (&icmp[1], 1802 GNUNET_memcpy (&icmp[1],
1803 &i2v[1], 1803 &i2v[1],
1804 mlen); 1804 mlen);
1805 /* For some ICMP types, we need to adjust (make up) the payload here. 1805 /* For some ICMP types, we need to adjust (make up) the payload here.
@@ -1936,7 +1936,7 @@ receive_icmp_back (void *cls,
1936 &ts->destination_ip.v6, 1936 &ts->destination_ip.v6,
1937 &ts->source_ip.v6); 1937 &ts->source_ip.v6);
1938 *icmp = i2v->icmp_header; 1938 *icmp = i2v->icmp_header;
1939 memcpy (&icmp[1], 1939 GNUNET_memcpy (&icmp[1],
1940 &i2v[1], 1940 &i2v[1],
1941 mlen); 1941 mlen);
1942 1942
@@ -2152,7 +2152,7 @@ receive_udp_back (void *cls,
2152 udp, 2152 udp,
2153 &reply[1], 2153 &reply[1],
2154 mlen); 2154 mlen);
2155 memcpy (&udp[1], 2155 GNUNET_memcpy (&udp[1],
2156 &reply[1], 2156 &reply[1],
2157 mlen); 2157 mlen);
2158 (void) GNUNET_HELPER_send (helper_handle, 2158 (void) GNUNET_HELPER_send (helper_handle,
@@ -2196,7 +2196,7 @@ receive_udp_back (void *cls,
2196 GNUNET_TUN_calculate_udp6_checksum (ipv6, 2196 GNUNET_TUN_calculate_udp6_checksum (ipv6,
2197 udp, 2197 udp,
2198 &reply[1], mlen); 2198 &reply[1], mlen);
2199 memcpy (&udp[1], 2199 GNUNET_memcpy (&udp[1],
2200 &reply[1], 2200 &reply[1],
2201 mlen); 2201 mlen);
2202 (void) GNUNET_HELPER_send (helper_handle, 2202 (void) GNUNET_HELPER_send (helper_handle,
@@ -2302,7 +2302,7 @@ receive_tcp_back (void *cls,
2302 tcp, 2302 tcp,
2303 &data[1], 2303 &data[1],
2304 mlen); 2304 mlen);
2305 memcpy (&tcp[1], 2305 GNUNET_memcpy (&tcp[1],
2306 &data[1], 2306 &data[1],
2307 mlen); 2307 mlen);
2308 (void) GNUNET_HELPER_send (helper_handle, 2308 (void) GNUNET_HELPER_send (helper_handle,
@@ -2341,7 +2341,7 @@ receive_tcp_back (void *cls,
2341 tcp, 2341 tcp,
2342 &data[1], 2342 &data[1],
2343 mlen); 2343 mlen);
2344 memcpy (&tcp[1], 2344 GNUNET_memcpy (&tcp[1],
2345 &data[1], 2345 &data[1],
2346 mlen); 2346 mlen);
2347 (void) GNUNET_HELPER_send (helper_handle, 2347 (void) GNUNET_HELPER_send (helper_handle,
@@ -2683,7 +2683,7 @@ service_redirect_to_ip (void *cls,
2683 de = GNUNET_new (struct DestinationEntry); 2683 de = GNUNET_new (struct DestinationEntry);
2684 de->is_service = GNUNET_NO; 2684 de->is_service = GNUNET_NO;
2685 de->details.exit_destination.af = addr_af; 2685 de->details.exit_destination.af = addr_af;
2686 memcpy (&de->details.exit_destination.ip, 2686 GNUNET_memcpy (&de->details.exit_destination.ip,
2687 &msg[1], 2687 &msg[1],
2688 alen); 2688 alen);
2689 get_destination_key_from_ip (result_af, 2689 get_destination_key_from_ip (result_af,
diff --git a/src/vpn/vpn_api.c b/src/vpn/vpn_api.c
index adba0a666..42fe7d4b4 100644
--- a/src/vpn/vpn_api.c
+++ b/src/vpn/vpn_api.c
@@ -278,7 +278,7 @@ send_request (struct GNUNET_VPN_RedirectionRequest *rr)
278 rip->result_af = htonl (rr->result_af); 278 rip->result_af = htonl (rr->result_af);
279 rip->addr_af = htonl (rr->addr_af); 279 rip->addr_af = htonl (rr->addr_af);
280 rip->request_id = rr->request_id = ++vh->request_id_gen; 280 rip->request_id = rr->request_id = ++vh->request_id_gen;
281 memcpy (&rip[1], 281 GNUNET_memcpy (&rip[1],
282 rr->addr, 282 rr->addr,
283 alen); 283 alen);
284 } 284 }
@@ -483,7 +483,7 @@ GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
483 rr->expiration_time = expiration_time; 483 rr->expiration_time = expiration_time;
484 rr->result_af = result_af; 484 rr->result_af = result_af;
485 rr->addr_af = addr_af; 485 rr->addr_af = addr_af;
486 memcpy (&rr[1], 486 GNUNET_memcpy (&rr[1],
487 addr, 487 addr,
488 alen); 488 alen);
489 GNUNET_CONTAINER_DLL_insert_tail (vh->rr_head, 489 GNUNET_CONTAINER_DLL_insert_tail (vh->rr_head,