From f1e91d7f37c76c2cef9c5dc298adc2602a289af4 Mon Sep 17 00:00:00 2001 From: smorlat Date: Sat, 14 Mar 2009 20:49:30 +0000 Subject: [PATCH] fix stack overflow when using linphonecsh in a case where authentication prompt is asked. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@342 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/console/commands.c | 4 +++- linphone/console/linphonec.c | 28 ++++++++++++++++------------ linphone/coreapi/authentication.c | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/linphone/console/commands.c b/linphone/console/commands.c index f049694d5..b27d92a01 100644 --- a/linphone/console/commands.c +++ b/linphone/console/commands.c @@ -1256,7 +1256,9 @@ static int lpc_cmd_register(LinphoneCore *lc, char *args){ LinphoneAuthInfo *info; osip_from_init(&from); if (osip_from_parse(from,identity)==0){ - info=linphone_auth_info_new(from->url->username,NULL,passwd,NULL,from->url->host); + char realm[128]; + snprintf(realm,sizeof(realm)-1,"\"%s\"",from->url->host); + info=linphone_auth_info_new(from->url->username,NULL,passwd,NULL,realm); linphone_core_add_auth_info(lc,info); } osip_from_free(from); diff --git a/linphone/console/linphonec.c b/linphone/console/linphonec.c index 1bdaaa613..6136eac3e 100644 --- a/linphone/console/linphonec.c +++ b/linphone/console/linphonec.c @@ -228,19 +228,23 @@ linphonec_call_received(LinphoneCore *lc, const char *from) static void linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username) { - LinphoneAuthInfo *pending_auth; - - if ( auth_stack.nitems+1 > MAX_PENDING_AUTH ) - { - fprintf(stderr, - "Can't accept another authentication request.\n" - "Consider incrementing MAX_PENDING_AUTH macro.\n"); - return; - } - - pending_auth=linphone_auth_info_new(username,NULL,NULL,NULL,realm); - auth_stack.elem[auth_stack.nitems++]=pending_auth; + /* no prompt possible when using pipes or tcp mode*/ + if (unix_socket || tcp_port){ + linphone_core_abort_authentication(lc,NULL); + }else{ + LinphoneAuthInfo *pending_auth; + if ( auth_stack.nitems+1 > MAX_PENDING_AUTH ) + { + fprintf(stderr, + "Can't accept another authentication request.\n" + "Consider incrementing MAX_PENDING_AUTH macro.\n"); + return; + } + + pending_auth=linphone_auth_info_new(username,NULL,NULL,NULL,realm); + auth_stack.elem[auth_stack.nitems++]=pending_auth; + } } /* diff --git a/linphone/coreapi/authentication.c b/linphone/coreapi/authentication.c index 437626bd6..c19aea1e6 100644 --- a/linphone/coreapi/authentication.c +++ b/linphone/coreapi/authentication.c @@ -137,7 +137,7 @@ static int realm_match(const char *realm1, const char *realm2){ char tmp2[128]; char *p1,*p2; strncpy(tmp1,realm1,sizeof(tmp1)-1); - strncpy(tmp2,realm2,sizeof(tmp1)-1); + strncpy(tmp2,realm2,sizeof(tmp2)-1); p1=remove_quotes(tmp1); p2=remove_quotes(tmp2); return strcmp(p1,p2)==0;