Prevent crash when an invalid SDP causes the adding of a losing pair with 2 addresses with different families.

This commit is contained in:
Ghislain MARY 2016-10-14 11:52:39 +02:00
parent a56c6bb514
commit a06c17055f

View file

@ -1862,6 +1862,7 @@ static void _create_ice_check_lists_and_parse_ice_attributes(LinphoneCall *call,
const char *addr = NULL;
int port = 0;
int componentID = 0;
int remote_family;
int family;
int i, j;
@ -1910,10 +1911,17 @@ static void _create_ice_check_lists_and_parse_ice_attributes(LinphoneCall *call,
/* If we receive a re-invite and we finished ICE processing on our side, use the candidates given by the remote. */
ice_check_list_unselect_valid_pairs(cl);
}
if (strchr(remote_candidate->addr, ':') != NULL) family = AF_INET6;
if (strchr(remote_candidate->addr, ':') != NULL) remote_family = AF_INET6;
else remote_family = AF_INET;
if (strchr(addr, ':') != NULL) family = AF_INET6;
else family = AF_INET;
ice_add_losing_pair(cl, j + 1, family, remote_candidate->addr, remote_candidate->port, addr, port);
losing_pairs_added = TRUE;
if (remote_family == family) {
ice_add_losing_pair(cl, j + 1, family, remote_candidate->addr, remote_candidate->port, addr, port);
losing_pairs_added = TRUE;
} else {
ms_error("Cannot add ICE losing pair this local and remote candidates having different address families.");
}
}
if (losing_pairs_added == TRUE) ice_check_list_check_completed(cl);
}