From 53128dec9d7d558ceb2ddc5d90777a32e4b08bbc Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 22 May 2013 17:40:26 +0200 Subject: [PATCH] avoid crash with op->auth_info --- coreapi/bellesip_sal/sal_impl.c | 14 ++++++-------- coreapi/bellesip_sal/sal_op_registration.c | 2 +- coreapi/callbacks.c | 6 +++--- mediastreamer2 | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 1609703a4..91c004962 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -363,14 +363,12 @@ static void process_transaction_terminated(void *user_ctx, const belle_sip_trans } static void process_auth_requested(void *sal, belle_sip_auth_event_t *auth_event) { - SalAuthInfo auth_info; - memset(&auth_info,0,sizeof(SalAuthInfo)); - auth_info.username=(char*)belle_sip_auth_event_get_username(auth_event); - auth_info.realm=(char*)belle_sip_auth_event_get_realm(auth_event); - ((Sal*)sal)->callbacks.auth_requested(sal,&auth_info); - belle_sip_auth_event_set_passwd(auth_event,(const char*)auth_info.password); - belle_sip_auth_event_set_ha1(auth_event,(const char*)auth_info.ha1); - belle_sip_auth_event_set_userid(auth_event,(const char*)auth_info.userid); + SalAuthInfo* auth_info = sal_auth_info_create(auth_event); + ((Sal*)sal)->callbacks.auth_requested(sal,auth_info); + belle_sip_auth_event_set_passwd(auth_event,(const char*)auth_info->password); + belle_sip_auth_event_set_ha1(auth_event,(const char*)auth_info->ha1); + belle_sip_auth_event_set_userid(auth_event,(const char*)auth_info->userid); + sal_auth_info_delete(auth_info); return; } diff --git a/coreapi/bellesip_sal/sal_op_registration.c b/coreapi/bellesip_sal/sal_op_registration.c index 5683568b4..87eec5fcb 100644 --- a/coreapi/bellesip_sal/sal_op_registration.c +++ b/coreapi/bellesip_sal/sal_op_registration.c @@ -70,7 +70,7 @@ static void register_refresher_listener ( const belle_sip_refresher_t* refresher sal_add_pending_auth(op->base.root,op); if (status_code == 403) { /*in sase of 401 or 407, auth requested already invoked previouly*/ /*auth previouly pending, probably wrong pasword, give a chance to authenticate again*/ - op->base.root->callbacks.auth_failure(op,op->auth_info); + op->base.root->callbacks.auth_failure(op,op->auth_info); /*fixme*/ } } } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 0f977b911..08e7cf550 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -906,9 +906,9 @@ static void ping_reply(SalOp *op){ static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) { LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,sai->realm,sai->username); if (ai) { - sai->userid=ai->userid?ai->userid:ai->username; - sai->password=ai->passwd; - sai->ha1=ai->ha1; + sai->userid=ms_strdup(ai->userid?ai->userid:ai->username); + sai->password=ai->passwd?ms_strdup(ai->passwd):NULL; + sai->ha1=ai->ha1?ms_strdup(ai->ha1):NULL; ai->usecount++; ai->last_use_time=ms_time(NULL); return TRUE; diff --git a/mediastreamer2 b/mediastreamer2 index 3f06cd60f..c898f5af0 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3f06cd60f1864b8c811e0f4e4590991802ce5ea7 +Subproject commit c898f5af06498ea9c6848e4342fab65cd4adcc4f