Module: sip-router Branch: master Commit: 704c619f401b6286588c43c8dec9e04670f4ad43 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=704c619f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Oct 31 11:20:05 2011 +0100
sdpops: check for sdp structure after parse_sdp()
- the function can return 1 in case of no body - reported by Juha Heinanen
---
modules/sdpops/sdpops_mod.c | 46 +++++++++++++++++++++++++++++++++--------- 1 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/modules/sdpops/sdpops_mod.c b/modules/sdpops/sdpops_mod.c index 725dcf6..7923bf0 100644 --- a/modules/sdpops/sdpops_mod.c +++ b/modules/sdpops/sdpops_mod.c @@ -276,11 +276,16 @@ int sdp_remove_codecs_by_id(sip_msg_t* msg, str* codecs) return -1; }
- LM_ERR("attempting to remove codecs from sdp: [%.*s]\n", - codecs->len, codecs->s); - sdp = (sdp_info_t*)msg->body;
+ if(sdp==NULL) { + LM_DBG("No sdp body\n"); + return -1; + } + + LM_DBG("attempting to remove codecs from sdp: [%.*s]\n", + codecs->len, codecs->s); + sdp_session_num = 0; for(;;) { @@ -346,6 +351,7 @@ static int w_sdp_remove_codecs_by_id(sip_msg_t* msg, char* codecs, char* bar) */ int sdp_remove_codecs_by_name(sip_msg_t* msg, str* codecs) { + sdp_info_t *sdp = NULL; str idslist;
if(parse_sdp(msg) < 0) { @@ -353,10 +359,17 @@ int sdp_remove_codecs_by_name(sip_msg_t* msg, str* codecs) return -1; }
- LM_ERR("attempting to remove codecs from sdp: [%.*s]\n", + sdp = (sdp_info_t*)msg->body; + + if(sdp==NULL) { + LM_DBG("No sdp body\n"); + return -1; + } + + LM_DBG("attempting to remove codecs from sdp: [%.*s]\n", codecs->len, codecs->s);
- if(sdpops_build_ids_list((sdp_info_t*)msg->body, codecs, &idslist)<0) + if(sdpops_build_ids_list(sdp, codecs, &idslist)<0) return -1;
if(sdp_remove_codecs_by_id(msg, &idslist)<0) @@ -409,11 +422,16 @@ int sdp_keep_codecs_by_id(sip_msg_t* msg, str* codecs) return -1; }
- LM_ERR("attempting to keep codecs in sdp: [%.*s]\n", - codecs->len, codecs->s); - sdp = (sdp_info_t*)msg->body;
+ if(sdp==NULL) { + LM_DBG("No sdp body\n"); + return -1; + } + + LM_DBG("attempting to keep codecs in sdp: [%.*s]\n", + codecs->len, codecs->s); + sdp_session_num = 0; for(;;) { @@ -481,6 +499,7 @@ static int w_sdp_keep_codecs_by_id(sip_msg_t* msg, char* codecs, char* bar) */ int sdp_keep_codecs_by_name(sip_msg_t* msg, str* codecs) { + sdp_info_t *sdp = NULL; str idslist;
if(parse_sdp(msg) < 0) { @@ -488,10 +507,17 @@ int sdp_keep_codecs_by_name(sip_msg_t* msg, str* codecs) return -1; }
- LM_ERR("attempting to keep codecs in sdp: [%.*s]\n", + sdp = (sdp_info_t*)msg->body; + + if(sdp==NULL) { + LM_DBG("No sdp body\n"); + return -1; + } + + LM_DBG("attempting to keep codecs in sdp: [%.*s]\n", codecs->len, codecs->s);
- if(sdpops_build_ids_list((sdp_info_t*)msg->body, codecs, &idslist)<0) + if(sdpops_build_ids_list(sdp, codecs, &idslist)<0) return -1;
if(sdp_keep_codecs_by_id(msg, &idslist)<0)