diff options
author | Walter Doekes <walter+asterisk@wjd.nu> | 2016-11-30 16:31:39 +0100 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2016-12-08 08:19:38 -0600 |
commit | c796f00c35c43972bcbfa1cba55a8862f00248a9 (patch) | |
tree | b2fc9113c35fc7e9b0300d5a8f8edb4bb7c6c1b8 | |
parent | 2268834c41d5b00a33c463c2cdc7113a85c94d6e (diff) |
chan_sip: Do not allow non-SP/HTAB between header key and colon.
RFC says SIP headers look like:
HCOLON = *( SP / HTAB ) ":" SWS
SWS = [LWS] ; sep whitespace
LWS = [*WSP CRLF] 1*WSP ; linear whitespace
WSP = SP / HTAB ; from rfc2234
chan_sip implemented this:
HCOLON = *( LOWCTL / SP ) ":" SWS
LOWCTL = %x00-1F ; CTL without DEL
This discrepancy meant that SIP proxies in front of Asterisk with
chan_sip could pass on unknown headers with \x00-\x1F in them, which
would be treated by Asterisk as a different (known) header. For
example, the "To\x01:" header would gladly be forwarded by some proxies
as irrelevant, but chan_sip would treat it as the relevant "To:" header.
Those relying on a SIP proxy to scrub certain headers could mistakenly
get unexpected and unvalidated data fed to Asterisk.
This change fixes so chan_sip only considers SP/HTAB as valid tokens
before the colon, making it agree on the headers with other speakers of
SIP.
ASTERISK-26433 #close
AST-2016-009
Change-Id: I78086fbc524ac733b8f7f78cb423c91075fd489b
-rw-r--r-- | channels/chan_sip.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 44693ef32..7f22b96c8 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -8449,8 +8449,6 @@ static const char *__get_header(const struct sip_request *req, const char *name, * one afterwards. If you shouldn't do it, what absolute idiot decided it was * a good idea to say you can do it, and if you can do it, why in the hell would. * you say you shouldn't. - * Anyways, pedanticsipchecking controls whether we allow spaces before ':', - * and we always allow spaces after that for compatibility. */ const char *sname = find_alias(name, NULL); int x, len = strlen(name), slen = (sname ? 1 : 0); @@ -8463,10 +8461,10 @@ static const char *__get_header(const struct sip_request *req, const char *name, if (match || smatch) { /* skip name */ const char *r = header + (match ? len : slen ); - if (sip_cfg.pedanticsipchecking) { - r = ast_skip_blanks(r); + /* HCOLON has optional SP/HTAB; skip past those */ + while (*r == ' ' || *r == '\t') { + ++r; } - if (*r == ':') { *start = x+1; return ast_skip_blanks(r+1); |