Module: kamailio
Branch: master
Commit: 1682896e2971508e454448d2a89ba5ab10811a84
URL:
https://github.com/kamailio/kamailio/commit/1682896e2971508e454448d2a89ba5a…
Author: Luis Azedo <luis(a)2600hz.com>
Committer: Luis Azedo <luis(a)2600hz.com>
Date: 2015-12-16T20:50:41Z
presence : fix notify version when subs_node <> 3
when submode <> 3 the notify version is always the same (first watcher) for all
watchers
---
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/1682896e2971508e454448d2a89ba5a…
Patch:
https://github.com/kamailio/kamailio/commit/1682896e2971508e454448d2a89ba5a…
---
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;
}