From 7cf0e80eac6b2e04a07a60f41fa067aa37c9ad83 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 9 May 2016 12:05:11 +0200 Subject: [PATCH] sal_impl.c: discard out of dialog ACK with invalid to-tag --- coreapi/bellesip_sal/sal_impl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 43926027b..1c09787bc 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -241,14 +241,17 @@ static void process_request_event(void *ud, const belle_sip_request_event_t *eve } }else{ /*handle the case where we are receiving a request with to tag but it is not belonging to any dialog*/ - if (strcmp("INVITE",method)==0 || strcmp("NOTIFY",method)==0) { - belle_sip_header_to_t *to = belle_sip_message_get_header_by_type(req, belle_sip_header_to_t); - if (belle_sip_header_to_get_tag(to) != NULL){ - ms_warning("Receiving %s with to-tag but no know dialog here. Rejecting.", method); - resp=belle_sip_response_create_from_request(req,481); - belle_sip_provider_send_response(sal->prov,resp); - return; - } + belle_sip_header_to_t *to = belle_sip_message_get_header_by_type(req, belle_sip_header_to_t); + if ((strcmp("INVITE",method)==0 || strcmp("NOTIFY",method)==0) && (belle_sip_header_to_get_tag(to) != NULL)) { + ms_warning("Receiving %s with to-tag but no know dialog here. Rejecting.", method); + resp=belle_sip_response_create_from_request(req,481); + belle_sip_provider_send_response(sal->prov,resp); + return; + /* by default (eg. when a to-tag is present), out of dialog ACK are automatically + handled in lower layers (belle-sip) but in case it misses, it will be forwarded to us */ + } else if (strcmp("ACK",method)==0 && (belle_sip_header_to_get_tag(to) == NULL)) { + ms_warning("Receiving ACK without to-tag but no know dialog here. Ignoring"); + return; } if (strcmp("INVITE",method)==0) {