summaryrefslogtreecommitdiff
path: root/toxcore/onion.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-12-31 12:30:39 -0500
committerirungentoo <irungentoo@gmail.com>2014-12-31 12:30:39 -0500
commit8ff85f09cbc78da99b0a11f59728ad110b2a4a6b (patch)
tree6e8fbe33135e08ed979604498360ceaa47bbcc53 /toxcore/onion.c
parent523cc20eb0ae5f67a3848d27c2cd3d910ac6da2f (diff)
Check if received ip family is valid for the onion packets.
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r--toxcore/onion.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c
index 0982a2b0..1ce8146e 100644
--- a/toxcore/onion.c
+++ b/toxcore/onion.c
@@ -294,7 +294,9 @@ int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port
294 294
295 IP_Port send_to; 295 IP_Port send_to;
296 ipport_unpack(&send_to, plain); 296 ipport_unpack(&send_to, plain);
297 to_host_family(&send_to.ip); 297
298 if (to_host_family(&send_to.ip) == -1)
299 return 1;
298 300
299 uint8_t ip_port[SIZE_IPPORT]; 301 uint8_t ip_port[SIZE_IPPORT];
300 ipport_pack(ip_port, &source); 302 ipport_pack(ip_port, &source);
@@ -343,7 +345,9 @@ static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, ui
343 345
344 IP_Port send_to; 346 IP_Port send_to;
345 ipport_unpack(&send_to, plain); 347 ipport_unpack(&send_to, plain);
346 to_host_family(&send_to.ip); 348
349 if (to_host_family(&send_to.ip) == -1)
350 return 1;
347 351
348 uint8_t data[ONION_MAX_PACKET_SIZE]; 352 uint8_t data[ONION_MAX_PACKET_SIZE];
349 data[0] = NET_PACKET_ONION_SEND_2; 353 data[0] = NET_PACKET_ONION_SEND_2;
@@ -392,7 +396,9 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui
392 396
393 IP_Port send_to; 397 IP_Port send_to;
394 ipport_unpack(&send_to, plain); 398 ipport_unpack(&send_to, plain);
395 to_host_family(&send_to.ip); 399
400 if (to_host_family(&send_to.ip) == -1)
401 return 1;
396 402
397 uint8_t data[ONION_MAX_PACKET_SIZE]; 403 uint8_t data[ONION_MAX_PACKET_SIZE];
398 memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT); 404 memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT);