Module: kamailio Branch: master Commit: 150ab9d445da9f7eca1c7312cb70ba176f320131 URL: https://github.com/kamailio/kamailio/commit/150ab9d445da9f7eca1c7312cb70ba17...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2020-06-13T11:33:52+02:00
siputils: add quotes around contact uri if not there for param encoding
---
Modified: src/modules/siputils/contact_ops.c
---
Diff: https://github.com/kamailio/kamailio/commit/150ab9d445da9f7eca1c7312cb70ba17... Patch: https://github.com/kamailio/kamailio/commit/150ab9d445da9f7eca1c7312cb70ba17...
---
diff --git a/src/modules/siputils/contact_ops.c b/src/modules/siputils/contact_ops.c index 9f3e09ca46..65168bfc45 100644 --- a/src/modules/siputils/contact_ops.c +++ b/src/modules/siputils/contact_ops.c @@ -638,6 +638,8 @@ int ki_contact_param_encode(sip_msg_t *msg, str *nparam, str *saddr) str nuri; char bval[MAX_URI_SIZE]; str pval; + int q; + char *p;
if((msg->contact == NULL) && ((parse_headers(msg, HDR_CONTACT_F, 0) == -1) @@ -677,9 +679,19 @@ int ki_contact_param_encode(sip_msg_t *msg, str *nparam, str *saddr) PKG_MEM_ERROR; return -1; } - nuri.len = snprintf(nuri.s, MAX_URI_SIZE-1, "%.*s;%.*s=%.*s", - saddr->len, saddr->s, nparam->len, nparam->s, - pval.len, pval.s); + q = 1; + for(p = c->uri.s-1; p > msg->buf; p++) { + if(*p == '<') { + q = 0; + break; + } + if(*p != ' ' && *p != '\t' && *p != '\n' && *p != '\n') { + break; + } + } + nuri.len = snprintf(nuri.s, MAX_URI_SIZE-1, "%s%.*s;%.*s=%.*s%s", + (q)?"<":"", saddr->len, saddr->s, nparam->len, nparam->s, + pval.len, pval.s, (q)?">":""); if(nuri.len<=0 || nuri.len>=MAX_URI_SIZE) { LM_ERR("failed to build the new contact for [%.*s] uri (%d)\n", c->uri.len, c->uri.s, nuri.len);