diff options
-rw-r--r-- | toxcore/onion.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c index 067b3907..479c6209 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -195,6 +195,9 @@ int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uin | |||
195 | ipport_unpack(&send_to, plain); | 195 | ipport_unpack(&send_to, plain); |
196 | to_host_family(&send_to.ip); | 196 | to_host_family(&send_to.ip); |
197 | 197 | ||
198 | uint8_t ip_port[SIZE_IPPORT]; | ||
199 | ipport_pack(ip_port, &source); | ||
200 | |||
198 | uint8_t data[ONION_MAX_PACKET_SIZE]; | 201 | uint8_t data[ONION_MAX_PACKET_SIZE]; |
199 | data[0] = NET_PACKET_ONION_SEND_1; | 202 | data[0] = NET_PACKET_ONION_SEND_1; |
200 | memcpy(data + 1, nonce, crypto_box_NONCEBYTES); | 203 | memcpy(data + 1, nonce, crypto_box_NONCEBYTES); |
@@ -202,7 +205,7 @@ int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uin | |||
202 | uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); | 205 | uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); |
203 | uint8_t *ret_part = data + data_len; | 206 | uint8_t *ret_part = data + data_len; |
204 | new_nonce(ret_part); | 207 | new_nonce(ret_part); |
205 | len = encrypt_data_symmetric(onion->secret_symmetric_key, ret_part, (uint8_t *)&source, SIZE_IPPORT, | 208 | len = encrypt_data_symmetric(onion->secret_symmetric_key, ret_part, ip_port, SIZE_IPPORT, |
206 | ret_part + crypto_box_NONCEBYTES); | 209 | ret_part + crypto_box_NONCEBYTES); |
207 | 210 | ||
208 | if (len != SIZE_IPPORT + crypto_box_MACBYTES) | 211 | if (len != SIZE_IPPORT + crypto_box_MACBYTES) |