Module: kamailio Branch: master Commit: 6dd065629604a32081d5e7b63bbbd292f56aaf23 URL: https://github.com/kamailio/kamailio/commit/6dd065629604a32081d5e7b63bbbd292...
Author: lazedo luis.azedo@factorlusitano.com Committer: lazedo luis.azedo@factorlusitano.com Date: 2015-12-17T17:49:37Z
Merge pull request #448 from kamailio/lazedo/fix_blf
presence : fix notify version when subs_mode <> 3
---
Modified: modules/presence/notify.c Modified: modules/presence_dialoginfo/add_events.c Modified: modules/presence_dialoginfo/notify_body.c
---
Diff: https://github.com/kamailio/kamailio/commit/6dd065629604a32081d5e7b63bbbd292... Patch: https://github.com/kamailio/kamailio/commit/6dd065629604a32081d5e7b63bbbd292...
---
diff --git a/modules/presence/notify.c b/modules/presence/notify.c index 6466fc1..efb8a48 100644 --- a/modules/presence/notify.c +++ b/modules/presence/notify.c @@ -1470,6 +1470,7 @@ int send_notify_request(subs_t* subs, subs_t * watcher_subs, c_back_param *cb_param= NULL; str* final_body= NULL; uac_req_t uac_r; + str* aux_body = NULL; LM_DBG("dialog info:\n"); printf_subs(subs); @@ -1532,7 +1533,12 @@ int send_notify_request(subs_t* subs, subs_t * watcher_subs, /* call aux_body_processing if exists */ if(subs->event->aux_body_processing) { - subs->event->aux_body_processing(subs, notify_body); + aux_body = subs->event->aux_body_processing(subs, notify_body); + if(aux_body) { + xmlFree(notify_body->s); + pkg_free(notify_body); + notify_body = aux_body; + } }
/* apply authorization rules if exists */ diff --git a/modules/presence_dialoginfo/add_events.c b/modules/presence_dialoginfo/add_events.c index fe1e416..8382fc7 100644 --- a/modules/presence_dialoginfo/add_events.c +++ b/modules/presence_dialoginfo/add_events.c @@ -57,6 +57,7 @@ int dlginfo_add_events(void)
/* modify XML body for each watcher to set the correct "version" */ event.aux_body_processing = dlginfo_body_setversion; + event.aux_free_body = free_xml_body;
if (pres_add_event(&event) < 0) { diff --git a/modules/presence_dialoginfo/notify_body.c b/modules/presence_dialoginfo/notify_body.c index 5db2a98..9ad377c 100644 --- a/modules/presence_dialoginfo/notify_body.c +++ b/modules/presence_dialoginfo/notify_body.c @@ -538,6 +538,7 @@ str *dlginfo_body_setversion(subs_t *subs, str *body) { char *version_start=0; char version[MAX_INT_LEN + 2]; /* +2 becasue of trailing " and \0 */ int version_len; + str* aux_body = NULL;
if (!body) { return NULL; @@ -564,9 +565,29 @@ str *dlginfo_body_setversion(subs_t *subs, str *body) { version_len = snprintf(version, MAX_INT_LEN + 2,"%d"", subs->version); if (version_len >= MAX_INT_LEN + 2) { LM_ERR("failed to convert 'version' to string\n"); - memcpy(version_start, "00000000000"", 12); return NULL; } + + aux_body= (str*)pkg_malloc(sizeof(str)); + if(aux_body== NULL) + { + ERR_MEM(PKG_MEM_STR); + return NULL; + } + memset(aux_body, 0, sizeof(str)); + aux_body->s= (char*)pkg_malloc( body->len * sizeof(char)); + if(aux_body->s== NULL) + { + pkg_free(aux_body); + ERR_MEM(PKG_MEM_STR); + return NULL; + } + memcpy(aux_body->s, body->s, body->len); + aux_body->len= body->len; + + /* again but on the copied str, no checks needed */ + version_start = strstr(aux_body->s + 34, "version="); + version_start += 9; /* Replace the placeholder 00000000000 with the version. * Put the padding behind the "" */ @@ -574,5 +595,5 @@ str *dlginfo_body_setversion(subs_t *subs, str *body) { memcpy(version_start, version, version_len); memset(version_start + version_len, ' ', 12 - version_len);
- return NULL; + return aux_body; }