Module: kamailio
Branch: master
Commit: b60b337e04f41d4b5262cb068f1bef6f827dba27
URL:
https://github.com/kamailio/kamailio/commit/b60b337e04f41d4b5262cb068f1bef6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-01-04T23:55:18+01:00
tm: safety check for CRLF at end of custom headers for local requests
- if hdrs value is not ending in '\n', add '\r\n'
---
Modified: modules/tm/t_msgbuilder.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b60b337e04f41d4b5262cb068f1bef6…
Patch:
https://github.com/kamailio/kamailio/commit/b60b337e04f41d4b5262cb068f1bef6…
---
diff --git a/modules/tm/t_msgbuilder.c b/modules/tm/t_msgbuilder.c
index f705b90..ded1b47 100644
--- a/modules/tm/t_msgbuilder.c
+++ b/modules/tm/t_msgbuilder.c
@@ -1553,7 +1553,13 @@ char* build_uac_req(str* method, str* headers, str* body, dlg_t*
dialog, int bra
*len += CONTENT_LENGTH_LEN + content_length.len + CRLF_LEN; /* Content-Length */
*len += ((server_signature && user_agent_hdr.len>0)
? (user_agent_hdr.len + CRLF_LEN) : 0); /* Signature */
- *len += (headers ? headers->len : 0);
/* Additional headers */
+ if(headers && headers->len>2) {
+ /* Additional headers */
+ *len += headers->len;
+ /* End of header if missing */
+ if(headers->s[headers->len - 1] != '\n')
+ *len += CRLF_LEN;
+ }
*len += (body ? body->len : 0);
/* Message body */
*len += CRLF_LEN;
/* End of Header */
@@ -1586,7 +1592,11 @@ char* build_uac_req(str* method, str* headers, str* body, dlg_t*
dialog, int bra
memapp(w, user_agent_hdr.s, user_agent_hdr.len);
memapp(w, CRLF, CRLF_LEN);
}
- if (headers) memapp(w, headers->s, headers->len);
+ if(headers && headers->len>2) {
+ memapp(w, headers->s, headers->len);
+ if(headers->s[headers->len - 1] != '\n')
+ memapp(w, CRLF, CRLF_LEN);
+ }
memapp(w, CRLF, CRLF_LEN);
if (body) memapp(w, body->s, body->len);