Fixed some portability issues.

This commit is contained in:
irungentoo 2014-01-21 07:31:19 -05:00
parent bba5176f28
commit 4e1bc481c5
2 changed files with 14 additions and 0 deletions

View File

@ -50,6 +50,7 @@ int send_onion_packet(DHT *dht, Node_format *nodes, uint8_t *data, uint32_t leng
return -1;
uint8_t step1[sizeof(IP_Port) + length];
to_net_family(&nodes[3].ip_port.ip);
memcpy(step1, &nodes[3].ip_port, sizeof(IP_Port));
memcpy(step1 + sizeof(IP_Port), data, length);
@ -60,6 +61,7 @@ int send_onion_packet(DHT *dht, Node_format *nodes, uint8_t *data, uint32_t leng
crypto_box_keypair(random_public_key, random_secret_key);
uint8_t step2[sizeof(IP_Port) + SEND_BASE + length];
to_net_family(&nodes[2].ip_port.ip);
memcpy(step2, &nodes[2].ip_port, sizeof(IP_Port));
memcpy(step2 + sizeof(IP_Port), random_public_key, crypto_box_PUBLICKEYBYTES);
@ -71,6 +73,7 @@ int send_onion_packet(DHT *dht, Node_format *nodes, uint8_t *data, uint32_t leng
crypto_box_keypair(random_public_key, random_secret_key);
uint8_t step3[sizeof(IP_Port) + SEND_BASE * 2 + length];
to_net_family(&nodes[1].ip_port.ip);
memcpy(step3, &nodes[1].ip_port, sizeof(IP_Port));
memcpy(step3 + sizeof(IP_Port), random_public_key, crypto_box_PUBLICKEYBYTES);
len = encrypt_data(nodes[1].client_id, random_secret_key, nonce,
@ -134,6 +137,8 @@ static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, ui
IP_Port send_to;
memcpy(&send_to, plain, sizeof(IP_Port));
to_host_family(&send_to.ip);
uint8_t data[MAX_ONION_SIZE];
data[0] = NET_PACKET_ONION_SEND_1;
memcpy(data + 1, packet + 1, crypto_box_NONCEBYTES);
@ -176,6 +181,8 @@ static int handle_send_1(void *object, IP_Port source, uint8_t *packet, uint32_t
IP_Port send_to;
memcpy(&send_to, plain, sizeof(IP_Port));
to_host_family(&send_to.ip);
uint8_t data[MAX_ONION_SIZE];
data[0] = NET_PACKET_ONION_SEND_2;
memcpy(data + 1, packet + 1, crypto_box_NONCEBYTES);
@ -221,6 +228,8 @@ static int handle_send_2(void *object, IP_Port source, uint8_t *packet, uint32_t
IP_Port send_to;
memcpy(&send_to, plain, sizeof(IP_Port));
to_host_family(&send_to.ip);
uint8_t data[MAX_ONION_SIZE];
memcpy(data, plain + sizeof(IP_Port), len - sizeof(IP_Port));
uint32_t data_len = (len - sizeof(IP_Port));

View File

@ -537,6 +537,11 @@ static int send_fakeid_announce(Onion_Client *onion_c, uint16_t friend_num, uint
memcpy(data + 1 + sizeof(uint64_t), onion_c->dht->self_public_key, crypto_box_PUBLICKEYBYTES);
Node_format nodes[MAX_SENT_NODES];
uint16_t num_nodes = closelist_nodes(onion_c->dht, nodes, MAX_SENT_NODES);
uint32_t i;
for (i = 0; i < num_nodes; ++i)
to_net_family(&nodes[i].ip_port.ip);
memcpy(data + FAKEID_DATA_MIN_LENGTH, nodes, sizeof(Node_format) * num_nodes);
int num1 = -1, num2 = -1;