summaryrefslogtreecommitdiff
path: root/channels/sip/reqresp_parser.c
diff options
context:
space:
mode:
authorMatthew Nicholson <mnicholson@digium.com>2011-05-13 01:55:38 +0000
committerMatthew Nicholson <mnicholson@digium.com>2011-05-13 01:55:38 +0000
commit9066db432982e68b8d0290af779f220c0efb1c41 (patch)
tree2dd3e89bd7264b81fcf07685e03a33f31099c221 /channels/sip/reqresp_parser.c
parent1ad49f46ce6c7f9fe7be2143000d5729ef954371 (diff)
Merged revisions 318720 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r318720 | mnicholson | 2011-05-12 18:35:51 -0500 (Thu, 12 May 2011) | 4 lines Handle ipv6 addresses in the sent-by Via: field. This change fixes a regression in via header parsing and ipv6 handling. (closes issue #18951) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318785 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sip/reqresp_parser.c')
-rw-r--r--channels/sip/reqresp_parser.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c
index 9edf5bd45..64b0db31f 100644
--- a/channels/sip/reqresp_parser.c
+++ b/channels/sip/reqresp_parser.c
@@ -2302,8 +2302,9 @@ struct sip_via *parse_via(const char *header)
}
v->sent_by = ast_skip_blanks(v->sent_by);
- /* store the port */
- if ((parm = strchr(v->sent_by, ':'))) {
+ /* store the port, we have to handle ipv6 addresses containing ':'
+ * characters gracefully */
+ if (((parm = strchr(v->sent_by, ']')) && *(++parm) == ':') || (parm = strchr(v->sent_by, ':'))) {
char *endptr;
v->port = strtol(++parm, &endptr, 10);
@@ -2389,6 +2390,13 @@ AST_TEST_DEFINE(parse_via_test)
.expected_maddr = "224.0.0.1",
.expected_ttl = 1,
};
+ struct testdata t7 = {
+ .in = "SIP/2.0/UDP [::1]:5060",
+ .expected_protocol = "SIP/2.0/UDP",
+ .expected_sent_by = "[::1]:5060",
+ .expected_port = 5060,
+ .expected_branch = "",
+ };
switch (cmd) {
case TEST_INIT:
info->name = "parse_via_test";
@@ -2408,6 +2416,7 @@ AST_TEST_DEFINE(parse_via_test)
AST_LIST_INSERT_TAIL(&testdatalist, &t4, list);
AST_LIST_INSERT_TAIL(&testdatalist, &t5, list);
AST_LIST_INSERT_TAIL(&testdatalist, &t6, list);
+ AST_LIST_INSERT_TAIL(&testdatalist, &t7, list);
AST_LIST_TRAVERSE(&testdatalist, testdataptr, list) {