diff options
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r-- | toxcore/onion.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c index 60fdcce0..805770fa 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -78,12 +78,11 @@ static int ip_unpack(IP *target, const uint8_t *data, unsigned int data_size, bo | |||
78 | memcpy(target->ip6.uint8, data + 1, SIZE_IP6); | 78 | memcpy(target->ip6.uint8, data + 1, SIZE_IP6); |
79 | } | 79 | } |
80 | 80 | ||
81 | if (!disable_family_check) { | 81 | bool valid = disable_family_check || |
82 | return to_host_family(target); | 82 | target->family == TOX_AF_INET || |
83 | } | 83 | target->family == TOX_AF_INET6; |
84 | 84 | ||
85 | to_host_family(target); | 85 | return valid ? 0 : -1; |
86 | return 0; | ||
87 | } | 86 | } |
88 | 87 | ||
89 | static void ipport_pack(uint8_t *data, const IP_Port *source) | 88 | static void ipport_pack(uint8_t *data, const IP_Port *source) |
@@ -617,7 +616,9 @@ static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, ui | |||
617 | 616 | ||
618 | uint16_t data_len = length - (1 + RETURN_1); | 617 | uint16_t data_len = length - (1 + RETURN_1); |
619 | 618 | ||
620 | if (onion->recv_1_function && send_to.ip.family != AF_INET && send_to.ip.family != AF_INET6) { | 619 | if (onion->recv_1_function && |
620 | send_to.ip.family != TOX_AF_INET && | ||
621 | send_to.ip.family != TOX_AF_INET6) { | ||
621 | return onion->recv_1_function(onion->callback_object, send_to, packet + (1 + RETURN_1), data_len); | 622 | return onion->recv_1_function(onion->callback_object, send_to, packet + (1 + RETURN_1), data_len); |
622 | } | 623 | } |
623 | 624 | ||