summaryrefslogtreecommitdiff
path: root/toxcore/onion.c
diff options
context:
space:
mode:
authorEvgeny Kurnevsky <kurnevsky@gmail.com>2018-04-15 09:27:17 +0300
committerEvgeny Kurnevsky <kurnevsky@gmail.com>2018-04-15 09:51:41 +0300
commit6b97acb773622f9abca5ef305cd55bdef1ecc484 (patch)
treeb193734798c9f1c2cf6323aa96033f3fa576b903 /toxcore/onion.c
parent09478f99578df9d9fd477e0c0b53cb0d74c09e2a (diff)
Restrict packet kinds that can be sent through onion path.
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r--toxcore/onion.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c
index 48cc4d76..740c25ce 100644
--- a/toxcore/onion.c
+++ b/toxcore/onion.c
@@ -471,6 +471,15 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui
471 return 1; 471 return 1;
472 } 472 }
473 473
474 if (len <= SIZE_IPPORT) {
475 return 1;
476 }
477
478 if (plain[SIZE_IPPORT] != NET_PACKET_ANNOUNCE_REQUEST &&
479 plain[SIZE_IPPORT] != NET_PACKET_ONION_DATA_REQUEST) {
480 return 1;
481 }
482
474 IP_Port send_to; 483 IP_Port send_to;
475 484
476 if (ipport_unpack(&send_to, plain, len, 0) == -1) { 485 if (ipport_unpack(&send_to, plain, len, 0) == -1) {
@@ -514,6 +523,11 @@ static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, ui
514 return 1; 523 return 1;
515 } 524 }
516 525
526 if (packet[1 + RETURN_3] != NET_PACKET_ANNOUNCE_RESPONSE &&
527 packet[1 + RETURN_3] != NET_PACKET_ONION_DATA_RESPONSE) {
528 return 1;
529 }
530
517 change_symmetric_key(onion); 531 change_symmetric_key(onion);
518 532
519 uint8_t plain[SIZE_IPPORT + RETURN_2]; 533 uint8_t plain[SIZE_IPPORT + RETURN_2];
@@ -555,6 +569,11 @@ static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, ui
555 return 1; 569 return 1;
556 } 570 }
557 571
572 if (packet[1 + RETURN_2] != NET_PACKET_ANNOUNCE_RESPONSE &&
573 packet[1 + RETURN_2] != NET_PACKET_ONION_DATA_RESPONSE) {
574 return 1;
575 }
576
558 change_symmetric_key(onion); 577 change_symmetric_key(onion);
559 578
560 uint8_t plain[SIZE_IPPORT + RETURN_1]; 579 uint8_t plain[SIZE_IPPORT + RETURN_1];
@@ -596,6 +615,11 @@ static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, ui
596 return 1; 615 return 1;
597 } 616 }
598 617
618 if (packet[1 + RETURN_1] != NET_PACKET_ANNOUNCE_RESPONSE &&
619 packet[1 + RETURN_1] != NET_PACKET_ONION_DATA_RESPONSE) {
620 return 1;
621 }
622
599 change_symmetric_key(onion); 623 change_symmetric_key(onion);
600 624
601 uint8_t plain[SIZE_IPPORT]; 625 uint8_t plain[SIZE_IPPORT];