FreeCalypso > hg > themwi-system-sw
comparison sip-in/invite.c @ 76:21276f045026
sip-in: validate To header prior to tag addition
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 20 Sep 2022 16:40:07 -0800 |
parents | 5beb51de1bae |
children | fe39404092d9 |
comparison
equal
deleted
inserted
replaced
75:dd845c4933e1 | 76:21276f045026 |
---|---|
96 int ext_100rel_req, ext_100rel_sup, use_100rel, use_pcma; | 96 int ext_100rel_req, ext_100rel_sup, use_100rel, use_pcma; |
97 struct sdp_parse sdp_parse; | 97 struct sdp_parse sdp_parse; |
98 struct sdp_gen sdp_gen; | 98 struct sdp_gen sdp_gen; |
99 struct call *call; | 99 struct call *call; |
100 char *dp; | 100 char *dp; |
101 unsigned copylen; | 101 unsigned req_uri_len, to_hdr_len, copylen; |
102 int rc; | 102 int rc; |
103 | 103 |
104 /* extract called number from Request-URI */ | 104 /* extract called number from Request-URI */ |
105 rc = user_from_sip_uri(req->req_uri, uri_user, 12); | 105 rc = user_from_sip_uri(req->req_uri, uri_user, 12); |
106 if (rc < 0) { | 106 if (rc < 0) { |
146 rc = grok_from_header(ess->from, &gfrom); | 146 rc = grok_from_header(ess->from, &gfrom); |
147 if (rc < 0) { | 147 if (rc < 0) { |
148 start_response_out_msg(&resp, "400 Malformed From header"); | 148 start_response_out_msg(&resp, "400 Malformed From header"); |
149 goto error_resp; | 149 goto error_resp; |
150 } | 150 } |
151 /* validate To header for the purpose of tag addition */ | |
152 req_uri_len = strlen(req->req_uri); | |
153 to_hdr_len = strlen(ess->to); | |
154 if (to_hdr_len == req_uri_len) { | |
155 if (strcasecmp(ess->to, req->req_uri)) { | |
156 bad_to_header: start_response_out_msg(&resp, "400 Bad To header"); | |
157 goto error_resp; | |
158 } | |
159 } else if (to_hdr_len == req_uri_len + 2) { | |
160 if (ess->to[0] != '<') | |
161 goto bad_to_header; | |
162 if (strncasecmp(ess->to+1, req->req_uri, req_uri_len)) | |
163 goto bad_to_header; | |
164 if (ess->to[req_uri_len+1] != '>') | |
165 goto bad_to_header; | |
166 } else | |
167 goto bad_to_header; | |
151 /* check 100rel and catch any unsupported requirements */ | 168 /* check 100rel and catch any unsupported requirements */ |
152 supp_ext.name = "100rel"; | 169 supp_ext.name = "100rel"; |
153 supp_ext.req_flag = &ext_100rel_req; | 170 supp_ext.req_flag = &ext_100rel_req; |
154 supp_ext.sup_flag = &ext_100rel_sup; | 171 supp_ext.sup_flag = &ext_100rel_sup; |
155 ext_100rel_req = ext_100rel_sup = 0; | 172 ext_100rel_req = ext_100rel_sup = 0; |