Fix segfault in issue #463 (#464)

This commit is contained in:
Francesco Carli 2020-10-19 09:45:00 +02:00 committed by GitHub
parent ed25ff8d01
commit 0c3fdc4df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1055,23 +1055,18 @@ static int process_udp(n2n_sn_t * sss,
n2n_REGISTER_SUPER_ACK_t ack;
n2n_common_t cmn2;
uint8_t ackbuf[N2N_SN_PKTBUF_SIZE];
uint8_t tmpbuf[MAX_AVAILABLE_SPACE_FOR_ENTRIES];
uint8_t tmpbuf[MAX_AVAILABLE_SPACE_FOR_ENTRIES];
size_t encx=0;
struct sn_community *fed;
struct sn_community_regular_expression *re, *tmp_re;
struct peer_info *peer, *tmp_peer, *p;
struct peer_info *peer, *tmp_peer, *p;
int8_t allowed_match = -1;
uint8_t match = 0;
int match_length = 0;
int match_length = 0;
n2n_ip_subnet_t ipaddr;
int num = 0;
n2n_sock_t *tmp_sock;
n2n_mac_t *tmp_mac;
if(from_supernode != comm->is_federation) {
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER: from_supernode value doesn't correspond to the internal federation marking");
return -1;
}
int num = 0;
n2n_sock_t *tmp_sock;
n2n_mac_t *tmp_mac;
memset(&ack, 0, sizeof(n2n_REGISTER_SUPER_ACK_t));
@ -1154,6 +1149,11 @@ static int process_udp(n2n_sn_t * sss,
ack.sock.port = ntohs(sender_sock->sin_port);
memcpy(ack.sock.addr.v4, &(sender_sock->sin_addr.s_addr), IPV4_SIZE);
if(from_supernode != comm->is_federation) {
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER: from_supernode value doesn't correspond to the internal federation marking");
return -1;
}
/* Add sender's data to federation (or update it) */
if(comm->is_federation == IS_FEDERATION) {
p = add_sn_to_federation_by_mac_or_sock(sss,&(ack.sock),&(reg.edgeMac));