Module: kamailio Branch: master Commit: f1ab32ee4a0bf64017a0b05f2013b81d37d50208 URL: https://github.com/kamailio/kamailio/commit/f1ab32ee4a0bf64017a0b05f2013b81d...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-12-05T12:40:16+01:00
dialog: store call-id, r-uri, f-uri and t-uri with 0-ending char
- can simplify matching with standard string comparison and regexp
---
Modified: src/modules/dialog/dlg_hash.c
---
Diff: https://github.com/kamailio/kamailio/commit/f1ab32ee4a0bf64017a0b05f2013b81d... Patch: https://github.com/kamailio/kamailio/commit/f1ab32ee4a0bf64017a0b05f2013b81d...
---
diff --git a/src/modules/dialog/dlg_hash.c b/src/modules/dialog/dlg_hash.c index a6c8cdeb7b..30c1cf76d1 100644 --- a/src/modules/dialog/dlg_hash.c +++ b/src/modules/dialog/dlg_hash.c @@ -457,15 +457,16 @@ struct dlg_cell* build_new_dlg( str *callid, str *from_uri, str *to_uri, int len; char *p;
- len = sizeof(struct dlg_cell) + callid->len + from_uri->len + - to_uri->len + req_uri->len; + /* space for dialog structure and values with 0-ending char */ + len = sizeof(struct dlg_cell) + callid->len + 1 + from_uri->len + 1 + + to_uri->len + 1 + req_uri->len + 1; dlg = (struct dlg_cell*)shm_malloc( len ); if (dlg==0) { LM_ERR("no more shm mem (%d)\n",len); return 0; }
- memset( dlg, 0, len); + memset(dlg, 0, len); dlg->state = DLG_STATE_UNCONFIRMED; dlg->init_ts = (unsigned int)time(NULL);
@@ -476,23 +477,23 @@ struct dlg_cell* build_new_dlg( str *callid, str *from_uri, str *to_uri,
dlg->callid.s = p; dlg->callid.len = callid->len; - memcpy( p, callid->s, callid->len); - p += callid->len; + memcpy(p, callid->s, callid->len); + p += callid->len + 1;
dlg->from_uri.s = p; dlg->from_uri.len = from_uri->len; - memcpy( p, from_uri->s, from_uri->len); - p += from_uri->len; + memcpy(p, from_uri->s, from_uri->len); + p += from_uri->len + 1;
dlg->to_uri.s = p; dlg->to_uri.len = to_uri->len; - memcpy( p, to_uri->s, to_uri->len); - p += to_uri->len; + memcpy(p, to_uri->s, to_uri->len); + p += to_uri->len + 1;
dlg->req_uri.s = p; dlg->req_uri.len = req_uri->len; - memcpy( p, req_uri->s, req_uri->len); - p += req_uri->len; + memcpy(p, req_uri->s, req_uri->len); + p += req_uri->len + 1;
if ( p!=(((char*)dlg)+len) ) { LM_CRIT("buffer overflow\n");