From a06c17055f16b24f26d2cf9bed16f8738d850a21 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 14 Oct 2016 11:52:39 +0200 Subject: [PATCH] Prevent crash when an invalid SDP causes the adding of a losing pair with 2 addresses with different families. --- coreapi/misc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index e0acd816d..afc11a2f5 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -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); }