From 7fe41ec081bc41789d1d4bca4681ddf05af8bc07 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 21 Mar 2013 11:13:42 +0100 Subject: [PATCH 1/4] fix crash related to zrtp hello hash when adding video --- coreapi/linphonecall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index e9640701f..2770d4ada 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -271,7 +271,7 @@ void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall * l=make_codec_list(lc,lc->codecs_conf.video_codecs,0,NULL,-1); md->streams[1].payloads=l; // if ZRTP is enabled, put the hello hash into the audiostream's desc - if (call->videostream->ms.zrtp_context!=NULL){ + if (call->videostream && call->videostream->ms.zrtp_context!=NULL){ ortp_zrtp_get_hello_hash(call->videostream->ms.zrtp_context, md->streams[1].zrtp_hello_hash, sizeof(md->streams[1].zrtp_hello_hash)); From 2aba9114a4bd01ac823402793ccdbc6c6b1df075 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Mar 2013 10:56:44 +0100 Subject: [PATCH 2/4] change the way local interface is searched. --- coreapi/misc.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 35a58e200..158ab0add 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1110,7 +1110,18 @@ static int get_local_ip_for_with_connect(int type, const char *dest, char *resul } int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ + int err; strcpy(result,type==AF_INET ? "127.0.0.1" : "::1"); + + if (type==AF_INET) + dest="87.98.157.38"; /*a public IP address*/ + else dest="2a00:1450:8002::68"; + err=get_local_ip_for_with_connect(type,dest,result); + if (err==0) return 0; + + /* if the connect method failed, which happens when no default route is set, + * try to find 'the' running interface with getifaddrs*/ + #ifdef HAVE_GETIFADDRS if (dest==NULL) { /*we use getifaddrs for lookup of default interface */ @@ -1125,11 +1136,7 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ } } #endif - /*else use connect to find the best local ip address */ - if (type==AF_INET) - dest="87.98.157.38"; /*a public IP address*/ - else dest="2a00:1450:8002::68"; - return get_local_ip_for_with_connect(type,dest,result); + return 0; } #ifndef WIN32 From b37cdb67830e898ddde4228c87ef1514d31a32b9 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Mar 2013 10:58:25 +0100 Subject: [PATCH 3/4] fix previous commit. --- coreapi/misc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 158ab0add..738766746 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1113,9 +1113,11 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ int err; strcpy(result,type==AF_INET ? "127.0.0.1" : "::1"); - if (type==AF_INET) - dest="87.98.157.38"; /*a public IP address*/ - else dest="2a00:1450:8002::68"; + if (dest==NULL){ + if (type==AF_INET) + dest="87.98.157.38"; /*a public IP address*/ + else dest="2a00:1450:8002::68"; + } err=get_local_ip_for_with_connect(type,dest,result); if (err==0) return 0; From 606d3c0a25c0134836eae78ac142ddb05dc4be38 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Mar 2013 11:00:23 +0100 Subject: [PATCH 4/4] fix again --- coreapi/misc.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 738766746..26cdbe224 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1125,18 +1125,17 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ * try to find 'the' running interface with getifaddrs*/ #ifdef HAVE_GETIFADDRS - if (dest==NULL) { - /*we use getifaddrs for lookup of default interface */ - int found_ifs; - found_ifs=get_local_ip_with_getifaddrs(type,result,LINPHONE_IPADDR_SIZE); - if (found_ifs==1){ - return 0; - }else if (found_ifs<=0){ - /*absolutely no network on this machine */ - return -1; - } - } + /*we use getifaddrs for lookup of default interface */ + int found_ifs; + + found_ifs=get_local_ip_with_getifaddrs(type,result,LINPHONE_IPADDR_SIZE); + if (found_ifs==1){ + return 0; + }else if (found_ifs<=0){ + /*absolutely no network on this machine */ + return -1; + } #endif return 0; }