Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
static void smart_fuzz_sync_response(Messenger *m, GC_Chat *chat)
{
uint8_t data[MAX_GC_PACKET_SIZE];
U32_to_bytes(data, chat->self_public_key_hash);
uint32_t length = HASH_ID_BYTES;
size_t packed_addrs_size = (ENC_PUBLIC_KEY + sizeof(IP_Port)) * (chat->numpeers - 1);
if (HASH_ID_BYTES + packed_addrs_size > sizeof(data))
return;
GC_PeerAddress peer_addrs[chat->numpeers - 1];
uint32_t i, num = 0;
GC_PeerAddress self_addr;
memcpy(&self_addr.public_key, chat->self_public_key, ENC_PUBLIC_KEY);
ipport_self_copy(m->dht, &self_addr.ip_port);
copy_gc_peer_addr(&peer_addrs[num++], &self_addr);
for (i = 1; i < chat->numpeers; ++i) {
if (chat->gcc[i].confirmed)
copy_gc_peer_addr(&peer_addrs[num++], &chat->gcc[i].addr);
}
U32_to_bytes(data + length, num);
length += sizeof(uint32_t);
int addrs_len = pack_gc_addresses(data + length, sizeof(data) - length, peer_addrs, num);
length += addrs_len;
if (addrs_len <= 0)
return;
length = fuzz_gc_packet(data, length, random_int_range(3), sizeof(data));
send_gc_packet_all_peers(chat, data, length, GP_SYNC_RESPONSE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment