Module: sip-router
Branch: master
Commit: 74bf08ef30cf18fb609c2c067584f1515ede23da
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=74bf08e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon May 27 16:54:02 2013 +0200
core: enclose uri in angle brakets for redirect contact header
- safer for uri with parameters and no q
- reported by Dan Bogos
---
dset.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/dset.c b/dset.c
index 98be023..52521ce 100644
--- a/dset.c
+++ b/dset.c
@@ -461,9 +461,11 @@ char* print_dset(struct sip_msg* msg, int* len)
if (msg->new_uri.s) {
cnt = 1;
- *len = msg->new_uri.len;
+ *len = msg->new_uri.len + 1 /*'<'*/;
if (ruri_q != Q_UNSPECIFIED) {
- *len += 1 + Q_PARAM_LEN + len_q(ruri_q);
+ *len += Q_PARAM_LEN + len_q(ruri_q);
+ } else {
+ *len += 1 /*'>'*/;
}
} else {
cnt = 0;
@@ -476,9 +478,11 @@ char* print_dset(struct sip_msg* msg, int* len)
init_branch_iterator();
while ((uri.s = next_branch(&uri.len, &q, 0, 0, 0, 0, 0, 0, 0))) {
cnt++;
- *len += uri.len;
+ *len += uri.len + 1 /*'<'*/;
if (q != Q_UNSPECIFIED) {
- *len += 1 + Q_PARAM_LEN + len_q(q);
+ *len += Q_PARAM_LEN + len_q(q);
+ } else {
+ *len += 1 /*'>'*/;
}
}
@@ -494,9 +498,7 @@ char* print_dset(struct sip_msg* msg, int* len)
memcpy(dset, CONTACT, CONTACT_LEN);
p = dset + CONTACT_LEN;
if (msg->new_uri.s) {
- if (ruri_q != Q_UNSPECIFIED) {
- *p++ = '<';
- }
+ *p++ = '<';
memcpy(p, msg->new_uri.s, msg->new_uri.len);
p += msg->new_uri.len;
@@ -508,6 +510,8 @@ char* print_dset(struct sip_msg* msg, int* len)
qbuf = q2str(ruri_q, &qlen);
memcpy(p, qbuf, qlen);
p += qlen;
+ } else {
+ *p++ = '>';
}
i = 1;
} else {
@@ -521,9 +525,7 @@ char* print_dset(struct sip_msg* msg, int* len)
p += CONTACT_DELIM_LEN;
}
- if (q != Q_UNSPECIFIED) {
- *p++ = '<';
- }
+ *p++ = '<';
memcpy(p, uri.s, uri.len);
p += uri.len;
@@ -534,6 +536,8 @@ char* print_dset(struct sip_msg* msg, int* len)
qbuf = q2str(q, &qlen);
memcpy(p, qbuf, qlen);
p += qlen;
+ } else {
+ *p++ = '>';
}
i++;
}