Commit 0619bcbe authored by jehan's avatar jehan
Browse files

fix memleak

parent 3cc6f3b7
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUTH_INFO_H_
#define AUTH_INFO_H_
typedef struct belle_sip_auth_info belle_sip_auth_info_t;
const char* belle_sip_auth_info_get_username(const belle_sip_auth_info_t info);
void belle_sip_auth_info_set_username(belle_sip_auth_info_t info, const char* value);
const char* belle_sip_auth_info_get_userid(const belle_sip_auth_info_t info);
void belle_sip_auth_info_set_userid(belle_sip_auth_info_t info, const char* value);
const char* belle_sip_auth_info_get_realm(const belle_sip_auth_info_t info);
void belle_sip_auth_info_set_realm(belle_sip_auth_info_t info, const char* value);
const char* belle_sip_auth_info_get_passwd(const belle_sip_auth_info_t info);
void belle_sip_auth_info_set_passwd(belle_sip_auth_info_t info, const char* value);
const char* belle_sip_auth_info_get_ha1(const belle_sip_auth_info_t info);
void belle_sip_auth_info_set_ha1(belle_sip_auth_info_t info, const char* value);
#endif /* AUTH_INFO_H_ */
...@@ -137,7 +137,6 @@ typedef struct _belle_sip_response belle_sip_response_t; ...@@ -137,7 +137,6 @@ typedef struct _belle_sip_response belle_sip_response_t;
#include "belle-sip/utils.h" #include "belle-sip/utils.h"
#include "belle-sip/list.h" #include "belle-sip/list.h"
#include "belle-sip/auth-info.h"
#include "belle-sip/listener.h" #include "belle-sip/listener.h"
#include "belle-sip/mainloop.h" #include "belle-sip/mainloop.h"
#include "belle-sip/uri.h" #include "belle-sip/uri.h"
......
...@@ -48,6 +48,7 @@ static void belle_sip_authorization_destroy(authorization_context_t* object) { ...@@ -48,6 +48,7 @@ static void belle_sip_authorization_destroy(authorization_context_t* object) {
DESTROY_STRING(object,realm); DESTROY_STRING(object,realm);
DESTROY_STRING(object,nonce); DESTROY_STRING(object,nonce);
DESTROY_STRING(object,qop); DESTROY_STRING(object,qop);
DESTROY_STRING(object,opaque);
belle_sip_object_unref(object->callid); belle_sip_object_unref(object->callid);
belle_sip_free(object); belle_sip_free(object);
} }
...@@ -572,6 +573,7 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ ...@@ -572,6 +573,7 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ
belle_sip_header_call_id_t* call_id; belle_sip_header_call_id_t* call_id;
belle_sip_list_t* auth_context_lst; belle_sip_list_t* auth_context_lst;
belle_sip_list_t* authenticate_lst; belle_sip_list_t* authenticate_lst;
belle_sip_list_t* head;
belle_sip_header_www_authenticate_t* authenticate; belle_sip_header_www_authenticate_t* authenticate;
belle_sip_header_authorization_t* authorization; belle_sip_header_authorization_t* authorization;
...@@ -593,7 +595,7 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ ...@@ -593,7 +595,7 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ
call_id = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(resp),belle_sip_header_call_id_t); call_id = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(resp),belle_sip_header_call_id_t);
/*searching for authentication headers*/ /*searching for authentication headers*/
authenticate_lst = belle_sip_list_copy(belle_sip_message_get_headers(BELLE_SIP_MESSAGE(resp),BELLE_SIP_WWW_AUTHENTICATE)); head=authenticate_lst = belle_sip_list_copy(belle_sip_message_get_headers(BELLE_SIP_MESSAGE(resp),BELLE_SIP_WWW_AUTHENTICATE));
/*search for proxy authenticate*/ /*search for proxy authenticate*/
authenticate_lst=belle_sip_list_append_link(authenticate_lst,belle_sip_list_copy(belle_sip_message_get_headers(BELLE_SIP_MESSAGE(resp),BELLE_SIP_PROXY_AUTHENTICATE))); authenticate_lst=belle_sip_list_append_link(authenticate_lst,belle_sip_list_copy(belle_sip_message_get_headers(BELLE_SIP_MESSAGE(resp),BELLE_SIP_PROXY_AUTHENTICATE)));
/*update auth contexts with authenticate headers from response*/ /*update auth contexts with authenticate headers from response*/
...@@ -601,13 +603,14 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ ...@@ -601,13 +603,14 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ
authenticate=BELLE_SIP_HEADER_WWW_AUTHENTICATE(authenticate_lst->data); authenticate=BELLE_SIP_HEADER_WWW_AUTHENTICATE(authenticate_lst->data);
belle_sip_provider_update_or_create_auth_context(p,call_id,authenticate); belle_sip_provider_update_or_create_auth_context(p,call_id,authenticate);
} }
belle_sip_list_free(head);
} }
/*put authorization header if passwd found*/ /*put authorization header if passwd found*/
call_id = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request),belle_sip_header_call_id_t); call_id = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request),belle_sip_header_call_id_t);
from = BELLE_SIP_HEADER_ADDRESS(belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_FROM)); from = BELLE_SIP_HEADER_ADDRESS(belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_FROM));
from_uri = belle_sip_header_address_get_uri(from); from_uri = belle_sip_header_address_get_uri(from);
if ((auth_context_lst = belle_sip_provider_get_auth_context_by_call_id(p,call_id))) { if ((head=auth_context_lst = belle_sip_provider_get_auth_context_by_call_id(p,call_id))) {
/*we assume there no existing auth headers*/ /*we assume there no existing auth headers*/
for (;auth_context_lst!=NULL;auth_context_lst=auth_context_lst->next) { for (;auth_context_lst!=NULL;auth_context_lst=auth_context_lst->next) {
/*clear auth info*/ /*clear auth info*/
...@@ -634,8 +637,7 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ ...@@ -634,8 +637,7 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ
belle_sip_header_authorization_set_nonce(authorization,auth_context->nonce); belle_sip_header_authorization_set_nonce(authorization,auth_context->nonce);
belle_sip_header_authorization_set_qop(authorization,auth_context->qop); belle_sip_header_authorization_set_qop(authorization,auth_context->qop);
belle_sip_header_authorization_set_opaque(authorization,auth_context->opaque); belle_sip_header_authorization_set_opaque(authorization,auth_context->opaque);
belle_sip_header_authorization_set_uri(authorization,belle_sip_request_get_uri(request)/*belle_sip_uri_create(belle_sip_uri_get_user(belle_sip_request_get_uri(request)) belle_sip_header_authorization_set_uri(authorization,(belle_sip_uri_t*)belle_sip_object_ref(belle_sip_request_get_uri(request)));
,belle_sip_uri_get_host(belle_sip_request_get_uri(request)))*/);
belle_sip_header_authorization_set_nonce_count(authorization,++auth_context->nonce_count); belle_sip_header_authorization_set_nonce_count(authorization,++auth_context->nonce_count);
if (auth_event->ha1) { if (auth_event->ha1) {
ha1=auth_event->ha1; ha1=auth_event->ha1;
...@@ -653,9 +655,9 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ ...@@ -653,9 +655,9 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ
} else { } else {
belle_sip_message("No auth info found for call id [%s]",belle_sip_header_call_id_get_call_id(call_id)); belle_sip_message("No auth info found for call id [%s]",belle_sip_header_call_id_get_call_id(call_id));
} }
belle_sip_auth_event_destroy(auth_event);
} }
belle_sip_list_free(auth_context_lst); belle_sip_list_free(head);
} else { } else {
/*nothing to do*/ /*nothing to do*/
} }
......
...@@ -155,7 +155,9 @@ void unregister_user(belle_sip_stack_t * stack ...@@ -155,7 +155,9 @@ void unregister_user(belle_sip_stack_t * stack
belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req); belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t); belle_sip_client_transaction_send_request(t);
}else belle_sip_provider_send_request(prov,req); }else belle_sip_provider_send_request(prov,req);
belle_sip_stack_sleep(stack,33000); int i;
for(i=0;!is_register_ok && i<2 ;i++)
belle_sip_stack_sleep(stack,5000);
CU_ASSERT_EQUAL(is_register_ok,1); CU_ASSERT_EQUAL(is_register_ok,1);
CU_ASSERT_EQUAL(using_transaction,use_transaction); CU_ASSERT_EQUAL(using_transaction,use_transaction);
belle_sip_provider_remove_sip_listener(prov,l); belle_sip_provider_remove_sip_listener(prov,l);
...@@ -199,7 +201,9 @@ belle_sip_request_t* register_user_at_domain(belle_sip_stack_t * stack ...@@ -199,7 +201,9 @@ belle_sip_request_t* register_user_at_domain(belle_sip_stack_t * stack
belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req); belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t); belle_sip_client_transaction_send_request(t);
}else belle_sip_provider_send_request(prov,req); }else belle_sip_provider_send_request(prov,req);
belle_sip_stack_sleep(stack,33000); int i;
for(i=0;!is_register_ok && i<2 ;i++)
belle_sip_stack_sleep(stack,5000);
CU_ASSERT_EQUAL(is_register_ok,1); CU_ASSERT_EQUAL(is_register_ok,1);
CU_ASSERT_EQUAL(using_transaction,use_transaction); CU_ASSERT_EQUAL(using_transaction,use_transaction);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment