diff options
author | irungentoo <irungentoo@gmail.com> | 2014-08-11 15:48:33 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-08-11 15:48:33 -0400 |
commit | f83fcbb13c0ea9b23ded77ede487c9cd9171995f (patch) | |
tree | 67690631c135c1137d51abcba875bc3d740e5f5b /toxcore/onion.c | |
parent | 0faa2fbad28c093537b9e32bb1c5be2636e41fbc (diff) |
Added length check to onion_send_1().
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r-- | toxcore/onion.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c index 1915324f..33bb54ca 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -211,6 +211,12 @@ static int handle_send_initial(void *object, IP_Port source, const uint8_t *pack | |||
211 | 211 | ||
212 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce) | 212 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce) |
213 | { | 213 | { |
214 | if (len > ONION_MAX_PACKET_SIZE + SIZE_IPPORT - (1 + crypto_box_NONCEBYTES + ONION_RETURN_1)) | ||
215 | return 1; | ||
216 | |||
217 | if (len <= SIZE_IPPORT + SEND_BASE * 2) | ||
218 | return 1; | ||
219 | |||
214 | IP_Port send_to; | 220 | IP_Port send_to; |
215 | ipport_unpack(&send_to, plain); | 221 | ipport_unpack(&send_to, plain); |
216 | to_host_family(&send_to.ip); | 222 | to_host_family(&send_to.ip); |