Commit 359d16ff authored by Simon Morlat's avatar Simon Morlat
Browse files

fix invalid read because polarssl doesn't copy the cname, so we have to do it for it.

make sure channel can't disappear while there are listeners to be called for it.
parent e9af53b2
......@@ -359,8 +359,6 @@ const char * belle_sip_channel_get_transport_name(const belle_sip_channel_t *obj
return BELLE_SIP_OBJECT_VPTR(obj,belle_sip_channel_t)->transport;
}
int belle_sip_channel_send(belle_sip_channel_t *obj, const void *buf, size_t buflen){
update_inactivity_timer(obj);
return BELLE_SIP_OBJECT_VPTR(obj,belle_sip_channel_t)->channel_send(obj,buf,buflen);
......@@ -404,6 +402,11 @@ static void channel_invoke_state_listener(belle_sip_channel_t *obj){
belle_sip_list_free(list);
}
static void channel_invoke_state_listener_defered(belle_sip_channel_t *obj){
channel_invoke_state_listener(obj);
belle_sip_object_unref(obj);
}
void channel_set_state(belle_sip_channel_t *obj, belle_sip_channel_state_t state) {
belle_sip_message("channel %p: state %s",obj,belle_sip_channel_state_to_string(state));
obj->state=state;
......@@ -412,7 +415,8 @@ void channel_set_state(belle_sip_channel_t *obj, belle_sip_channel_state_t state
* it is safer to invoke the listener outside the current call stack.
* Indeed the channel encounters network errors while being called for transmiting by a transaction.
*/
belle_sip_main_loop_do_later(obj->stack->ml,(belle_sip_callback_t)channel_invoke_state_listener,obj);
belle_sip_object_ref(obj);
belle_sip_main_loop_do_later(obj->stack->ml,(belle_sip_callback_t)channel_invoke_state_listener_defered,obj);
}else
channel_invoke_state_listener(obj);
}
......@@ -516,7 +520,7 @@ static void channel_process_queue(belle_sip_channel_t *obj){
belle_sip_message_t *msg;
belle_sip_object_ref(obj);/* we need to ref ourself because code below may trigger our destruction*/
while((msg=channel_pop_outgoing(obj))!=NULL) {
while((msg=channel_pop_outgoing(obj))!=NULL && obj->state==BELLE_SIP_CHANNEL_READY) {
send_message(obj, msg);
belle_sip_object_unref(msg);
}
......
......@@ -224,7 +224,7 @@ belle_sip_channel_t * belle_sip_channel_new_tls(belle_sip_tls_listening_point_t
ssl_set_endpoint(&obj->sslctx,SSL_IS_CLIENT);
ssl_set_authmode(&obj->sslctx,SSL_VERIFY_REQUIRED);
ssl_set_bio(&obj->sslctx,polarssl_read,obj,polarssl_write,obj);
ssl_set_ca_chain(&obj->sslctx,&lp->root_ca,NULL,dest);
ssl_set_ca_chain(&obj->sslctx,&lp->root_ca,NULL,super->base.peer_cname);
ssl_set_rng(&obj->sslctx,random_generator,NULL);
ssl_set_verify(&obj->sslctx,belle_sip_ssl_verify,lp);
return (belle_sip_channel_t*)obj;
......
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