/src/opensips/parser/parse_uri.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2001-2003 FhG Fokus |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version |
10 | | * |
11 | | * opensips is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | * |
20 | | */ |
21 | | |
22 | | |
23 | | #ifndef PARSE_URI_H |
24 | | #define PARSE_URI_H |
25 | | |
26 | | /* |
27 | | * SIP URI parser |
28 | | */ |
29 | | |
30 | | |
31 | | #include "../ut.h" |
32 | | #include "../str.h" |
33 | | #include "../net/trans.h" |
34 | | #include "../parser/msg_parser.h" |
35 | | |
36 | 63.4k | #define SIP_SCH 0x3a706973 |
37 | 13.3k | #define SIPS_SCH 0x73706973 |
38 | 12.7k | #define TEL_SCH 0x3a6c6574 |
39 | 7.79k | #define URN_SERVICE_SCH 0x3a6e7275 |
40 | 5.69k | #define URN_SERVICE_STR ":service:" |
41 | 5.81k | #define URN_SERVICE_STR_LEN (sizeof(URN_SERVICE_STR) - 1) |
42 | 4.47k | #define URN_NENA_SERVICE_STR ":nena:service:" |
43 | 5.01k | #define URN_NENA_SERVICE_STR_LEN (sizeof(URN_NENA_SERVICE_STR) - 1) |
44 | | |
45 | | /* buf= pointer to beginning of uri (sip:x@foo.bar:5060;a=b?h=i) |
46 | | * len= len of uri |
47 | | * returns: fills uri & returns <0 on error or 0 if ok |
48 | | */ |
49 | | int parse_uri(char *buf, int len, struct sip_uri* uri); |
50 | | |
51 | | /* Trim a URI userinfo string in place at the first ';', dropping any user |
52 | | * parameters (e.g. the RFC 4904 'tgrp'/'trunk-context' fields) that parse_uri() |
53 | | * may have folded into the .user field along with the leading value. Callers |
54 | | * that only want that leading value (such as a telephone number for an E.164 |
55 | | * check) use this; a userinfo without parameters is left untouched. |
56 | | * |
57 | | * This is a naive cut at the first ';' with no escape/quote handling: it |
58 | | * assumes the leading value itself contains no literal ';' (true for RFC 4904 |
59 | | * telephone numbers). Do not use it on userinfo that may legitimately carry a |
60 | | * ';' in the value. Only .len is changed; .s keeps pointing at the original |
61 | | * buffer. |
62 | | */ |
63 | | void trim_user_params(str *user); |
64 | | |
65 | | /* |
66 | | * Fully prints a given "struct sip_uri" into a given buffer |
67 | | * |
68 | | * The following "struct sip_uri" fields can be disabled by setting to NULL: |
69 | | * - passwd / host / port |
70 | | * - transport / ttl / user_param / maddr / method / lr / r2 / gr |
71 | | * - any of the unknown param names |
72 | | * |
73 | | * Returns 0 on success, -1 on failure |
74 | | */ |
75 | | int print_uri(struct sip_uri *uri, str *out_buf); |
76 | | |
77 | | /* headers : the list of headers to parse (taken from uri structure) |
78 | | * h_name[] : array of header names |
79 | | * h_val[] : array of header values |
80 | | * h_size : size of header array */ |
81 | | int parse_uri_headers(str headers, str h_name[], str h_val[], int h_size); |
82 | | int parse_sip_msg_uri(struct sip_msg* msg); |
83 | | int parse_orig_ruri(struct sip_msg* msg); |
84 | | int compare_uris(str *raw_uri_a,struct sip_uri* parsed_uri_a, |
85 | | str *raw_uri_b,struct sip_uri *parsed_uri_b); |
86 | | static inline int get_uri_param_val(const struct sip_uri *uri, |
87 | | const str *param, str *val); |
88 | | static inline int get_uri_param_idx(const str *param, |
89 | | const struct sip_uri *parsed_uri); |
90 | | |
91 | | /** |
92 | | * Test a given char or an entire string against the allowed characters |
93 | | * of a SIP URI 'username' field. |
94 | | * |
95 | | * Return 1 (success), 0 (failure) |
96 | | */ |
97 | | static inline int is_username_char(char c); |
98 | | static inline int is_username_str(const str *username); |
99 | | |
100 | | /** |
101 | | * Test a given char or an entire string against the allowed characters |
102 | | * of a SIP URI 'uri-parameter' field. Works for both 'pname' |
103 | | * and 'pvalue'. |
104 | | * |
105 | | * Return 1 (success), 0 (failure) |
106 | | */ |
107 | | static inline int is_uri_parameter_char(char c); |
108 | | static inline int is_uri_parameter_str(const str *uri_param); |
109 | | |
110 | | char * uri_type2str(const uri_type type, char *result); |
111 | | int uri_typestrlen(const uri_type type); |
112 | | uri_type str2uri_type(char * buf); |
113 | | |
114 | | /* Gets (in a SIP wise manner) the SIP port from a SIP URI ; if the port |
115 | | is not explicitly set in the URI, it returns the default port corresponding |
116 | | to the used transport protocol (if protocol misses, we assume the default |
117 | | protos according to the URI schema) */ |
118 | | static inline unsigned short get_uri_port(struct sip_uri* _uri, |
119 | | unsigned short *_proto) |
120 | 6.41k | { |
121 | 6.41k | unsigned short port; |
122 | 6.41k | unsigned short proto; |
123 | | |
124 | | /* known protocol? */ |
125 | 6.41k | if ((proto=_uri->proto)==PROTO_NONE) { |
126 | | /* use UDP as default proto, but TLS for secure schemas */ |
127 | 5.88k | proto = (_uri->type==SIPS_URI_T || _uri->type==TELS_URI_T)? |
128 | 5.80k | PROTO_TLS : PROTO_UDP ; |
129 | 5.88k | } |
130 | | |
131 | | /* known port? */ |
132 | 6.41k | if ((port=_uri->port_no)==0) |
133 | 6.22k | port = protos[proto].default_rfc_port; |
134 | | |
135 | 6.41k | if (_proto) *_proto = proto; |
136 | | |
137 | 6.41k | return port; |
138 | 6.41k | } Unexecuted instantiation: msg_parser.c:get_uri_port Unexecuted instantiation: parse_uri.c:get_uri_port Unexecuted instantiation: parse_to.c:get_uri_port Unexecuted instantiation: strcommon.c:get_uri_port Unexecuted instantiation: transformations.c:get_uri_port Line | Count | Source | 120 | 6.41k | { | 121 | 6.41k | unsigned short port; | 122 | 6.41k | unsigned short proto; | 123 | | | 124 | | /* known protocol? */ | 125 | 6.41k | if ((proto=_uri->proto)==PROTO_NONE) { | 126 | | /* use UDP as default proto, but TLS for secure schemas */ | 127 | 5.88k | proto = (_uri->type==SIPS_URI_T || _uri->type==TELS_URI_T)? | 128 | 5.80k | PROTO_TLS : PROTO_UDP ; | 129 | 5.88k | } | 130 | | | 131 | | /* known port? */ | 132 | 6.41k | if ((port=_uri->port_no)==0) | 133 | 6.22k | port = protos[proto].default_rfc_port; | 134 | | | 135 | 6.41k | if (_proto) *_proto = proto; | 136 | | | 137 | 6.41k | return port; | 138 | 6.41k | } |
Unexecuted instantiation: parse_ppi.c:get_uri_port Unexecuted instantiation: parse_from.c:get_uri_port Unexecuted instantiation: core_cmds.c:get_uri_port Unexecuted instantiation: fuzz_uri_parser.c:get_uri_port |
139 | | |
140 | | |
141 | | /** |
142 | | * get_uri_param_val() - Fetch the value of a given URI parameter |
143 | | * @uri - parsed SIP URI |
144 | | * @param - URI param name to search for |
145 | | * @val - output value |
146 | | * |
147 | | * Return: |
148 | | * 0 on RFC-recognized parameters (even if they are missing!) |
149 | | * or successful search of unknown ones |
150 | | * -1 otherwise |
151 | | */ |
152 | | static inline int get_uri_param_val(const struct sip_uri *uri, |
153 | | const str *param, str *val) |
154 | 0 | { |
155 | 0 | int i; |
156 | 0 |
|
157 | 0 | if (ZSTR(*param)) |
158 | 0 | return -1; |
159 | 0 |
|
160 | 0 | switch (param->s[0]) { |
161 | 0 | case 'p': |
162 | 0 | case 'P': |
163 | 0 | if (str_casematch(param, const_str("pn-provider"))) { |
164 | 0 | *val = uri->pn_provider_val; |
165 | 0 | return 0; |
166 | 0 | } |
167 | 0 |
|
168 | 0 | if (str_casematch(param, const_str("pn-prid"))) { |
169 | 0 | *val = uri->pn_prid_val; |
170 | 0 | return 0; |
171 | 0 | } |
172 | 0 |
|
173 | 0 | if (str_casematch(param, const_str("pn-param"))) { |
174 | 0 | *val = uri->pn_param_val; |
175 | 0 | return 0; |
176 | 0 | } |
177 | 0 |
|
178 | 0 | if (str_casematch(param, const_str("pn-purr"))) { |
179 | 0 | *val = uri->pn_purr_val; |
180 | 0 | return 0; |
181 | 0 | } |
182 | 0 | break; |
183 | 0 |
|
184 | 0 | case 't': |
185 | 0 | case 'T': |
186 | 0 | if (str_casematch(param, const_str("transport"))) { |
187 | 0 | *val = uri->transport_val; |
188 | 0 | return 0; |
189 | 0 | } |
190 | 0 |
|
191 | 0 | if (str_casematch(param, const_str("ttl"))) { |
192 | 0 | *val = uri->ttl_val; |
193 | 0 | return 0; |
194 | 0 | } |
195 | 0 | break; |
196 | 0 |
|
197 | 0 | case 'u': |
198 | 0 | case 'U': |
199 | 0 | if (str_casematch(param, const_str("user"))) { |
200 | 0 | *val = uri->user_param_val; |
201 | 0 | return 0; |
202 | 0 | } |
203 | 0 | break; |
204 | 0 |
|
205 | 0 | case 'm': |
206 | 0 | case 'M': |
207 | 0 | if (str_casematch(param, const_str("maddr"))) { |
208 | 0 | *val = uri->maddr_val; |
209 | 0 | return 0; |
210 | 0 | } |
211 | 0 |
|
212 | 0 | if (str_casematch(param, const_str("method"))) { |
213 | 0 | *val = uri->method_val; |
214 | 0 | return 0; |
215 | 0 | } |
216 | 0 | break; |
217 | 0 |
|
218 | 0 | case 'l': |
219 | 0 | case 'L': |
220 | 0 | if (str_casematch(param, const_str("lr"))) { |
221 | 0 | *val = uri->lr_val; |
222 | 0 | return 0; |
223 | 0 | } |
224 | 0 | break; |
225 | 0 |
|
226 | 0 | case 'r': |
227 | 0 | case 'R': |
228 | 0 | if (str_casematch(param, const_str("r2"))) { |
229 | 0 | *val = uri->r2_val; |
230 | 0 | return 0; |
231 | 0 | } |
232 | 0 | break; |
233 | 0 |
|
234 | 0 | case 'g': |
235 | 0 | case 'G': |
236 | 0 | if (str_casematch(param, const_str("gr"))) { |
237 | 0 | *val = uri->gr_val; |
238 | 0 | return 0; |
239 | 0 | } |
240 | 0 | break; |
241 | 0 | } |
242 | 0 |
|
243 | 0 | for (i = 0; i < uri->u_params_no; i++) |
244 | 0 | if (str_match(param, &uri->u_name[i])) { |
245 | 0 | *val = uri->u_val[i]; |
246 | 0 | return 0; |
247 | 0 | } |
248 | 0 |
|
249 | 0 | return -1; |
250 | 0 | } Unexecuted instantiation: msg_parser.c:get_uri_param_val Unexecuted instantiation: parse_uri.c:get_uri_param_val Unexecuted instantiation: parse_to.c:get_uri_param_val Unexecuted instantiation: strcommon.c:get_uri_param_val Unexecuted instantiation: transformations.c:get_uri_param_val Unexecuted instantiation: pvar.c:get_uri_param_val Unexecuted instantiation: parse_ppi.c:get_uri_param_val Unexecuted instantiation: parse_from.c:get_uri_param_val Unexecuted instantiation: core_cmds.c:get_uri_param_val Unexecuted instantiation: fuzz_uri_parser.c:get_uri_param_val |
251 | | |
252 | | |
253 | | /* Unknown URI param index. |
254 | | * |
255 | | * Returns >= 0 on success, -1 on failure. |
256 | | */ |
257 | | static inline int get_uri_param_idx(const str *param, |
258 | | const struct sip_uri *parsed_uri) |
259 | 0 | { |
260 | 0 | int i; |
261 | 0 |
|
262 | 0 | for (i = 0; i < parsed_uri->u_params_no; i++) |
263 | 0 | if (str_match(&parsed_uri->u_name[i], param)) |
264 | 0 | return i; |
265 | 0 |
|
266 | 0 | return -1; |
267 | 0 | } Unexecuted instantiation: msg_parser.c:get_uri_param_idx Unexecuted instantiation: parse_uri.c:get_uri_param_idx Unexecuted instantiation: parse_to.c:get_uri_param_idx Unexecuted instantiation: strcommon.c:get_uri_param_idx Unexecuted instantiation: transformations.c:get_uri_param_idx Unexecuted instantiation: pvar.c:get_uri_param_idx Unexecuted instantiation: parse_ppi.c:get_uri_param_idx Unexecuted instantiation: parse_from.c:get_uri_param_idx Unexecuted instantiation: core_cmds.c:get_uri_param_idx Unexecuted instantiation: fuzz_uri_parser.c:get_uri_param_idx |
268 | | |
269 | | static inline int is_username_char(char c) |
270 | 0 | { |
271 | 0 | return (int[]){ |
272 | 0 | 0 /* 0 NUL */, |
273 | 0 | 0 /* 1 SOH */, |
274 | 0 | 0 /* 2 STX */, |
275 | 0 | 0 /* 3 ETX */, |
276 | 0 | 0 /* 4 EOT */, |
277 | 0 | 0 /* 5 ENQ */, |
278 | 0 | 0 /* 6 ACK */, |
279 | 0 | 0 /* 7 BEL */, |
280 | 0 | 0 /* 8 BS */, |
281 | 0 | 0 /* 9 HT */, |
282 | 0 | 0 /* 10 LF */, |
283 | 0 | 0 /* 11 VT */, |
284 | 0 | 0 /* 12 FF */, |
285 | 0 | 0 /* 13 CR */, |
286 | 0 | 0 /* 14 SO */, |
287 | 0 | 0 /* 15 SI */, |
288 | 0 | 0 /* 16 DLE */, |
289 | 0 | 0 /* 17 DC1 */, |
290 | 0 | 0 /* 18 DC2 */, |
291 | 0 | 0 /* 19 DC3 */, |
292 | 0 | 0 /* 20 DC4 */, |
293 | 0 | 0 /* 21 NAK */, |
294 | 0 | 0 /* 22 SYN */, |
295 | 0 | 0 /* 23 ETB */, |
296 | 0 | 0 /* 24 CAN */, |
297 | 0 | 0 /* 25 EM */, |
298 | 0 | 0 /* 26 SUB */, |
299 | 0 | 0 /* 27 ESC */, |
300 | 0 | 0 /* 28 FS */, |
301 | 0 | 0 /* 29 GS */, |
302 | 0 | 0 /* 30 RS */, |
303 | 0 | 0 /* 31 US */, |
304 | 0 | 0 /* 32 */, |
305 | 0 | 1 /* 33 ! */, |
306 | 0 | 0 /* 34 " */, |
307 | 0 | 0 /* 35 # */, |
308 | 0 | 1 /* 36 $ */, |
309 | 0 | 0 /* 37 % */, |
310 | 0 | 1 /* 38 & */, |
311 | 0 | 1 /* 39 ' */, |
312 | 0 | 1 /* 40 ( */, |
313 | 0 | 1 /* 41 ) */, |
314 | 0 | 1 /* 42 * */, |
315 | 0 | 1 /* 43 + */, |
316 | 0 | 1 /* 44 , */, |
317 | 0 | 1 /* 45 - */, |
318 | 0 | 1 /* 46 . */, |
319 | 0 | 1 /* 47 / */, |
320 | 0 | 1 /* 48 0 */, |
321 | 0 | 1 /* 49 1 */, |
322 | 0 | 1 /* 50 2 */, |
323 | 0 | 1 /* 51 3 */, |
324 | 0 | 1 /* 52 4 */, |
325 | 0 | 1 /* 53 5 */, |
326 | 0 | 1 /* 54 6 */, |
327 | 0 | 1 /* 55 7 */, |
328 | 0 | 1 /* 56 8 */, |
329 | 0 | 1 /* 57 9 */, |
330 | 0 | 0 /* 58 : */, |
331 | 0 | 1 /* 59 ; */, |
332 | 0 | 0 /* 60 < */, |
333 | 0 | 1 /* 61 = */, |
334 | 0 | 0 /* 62 > */, |
335 | 0 | 1 /* 63 ? */, |
336 | 0 | 0 /* 64 @ */, |
337 | 0 | 1 /* 65 A */, |
338 | 0 | 1 /* 66 B */, |
339 | 0 | 1 /* 67 C */, |
340 | 0 | 1 /* 68 D */, |
341 | 0 | 1 /* 69 E */, |
342 | 0 | 1 /* 70 F */, |
343 | 0 | 1 /* 71 G */, |
344 | 0 | 1 /* 72 H */, |
345 | 0 | 1 /* 73 I */, |
346 | 0 | 1 /* 74 J */, |
347 | 0 | 1 /* 75 K */, |
348 | 0 | 1 /* 76 L */, |
349 | 0 | 1 /* 77 M */, |
350 | 0 | 1 /* 78 N */, |
351 | 0 | 1 /* 79 O */, |
352 | 0 | 1 /* 80 P */, |
353 | 0 | 1 /* 81 Q */, |
354 | 0 | 1 /* 82 R */, |
355 | 0 | 1 /* 83 S */, |
356 | 0 | 1 /* 84 T */, |
357 | 0 | 1 /* 85 U */, |
358 | 0 | 1 /* 86 V */, |
359 | 0 | 1 /* 87 W */, |
360 | 0 | 1 /* 88 X */, |
361 | 0 | 1 /* 89 Y */, |
362 | 0 | 1 /* 90 Z */, |
363 | 0 | 0 /* 91 [ */, |
364 | 0 | 0 /* 92 \ */, |
365 | 0 | 0 /* 93 ] */, |
366 | 0 | 0 /* 94 ^ */, |
367 | 0 | 1 /* 95 _ */, |
368 | 0 | 0 /* 96 ` */, |
369 | 0 | 1 /* 97 a */, |
370 | 0 | 1 /* 98 b */, |
371 | 0 | 1 /* 99 c */, |
372 | 0 | 1 /* 100 d */, |
373 | 0 | 1 /* 101 e */, |
374 | 0 | 1 /* 102 f */, |
375 | 0 | 1 /* 103 g */, |
376 | 0 | 1 /* 104 h */, |
377 | 0 | 1 /* 105 i */, |
378 | 0 | 1 /* 106 j */, |
379 | 0 | 1 /* 107 k */, |
380 | 0 | 1 /* 108 l */, |
381 | 0 | 1 /* 109 m */, |
382 | 0 | 1 /* 110 n */, |
383 | 0 | 1 /* 111 o */, |
384 | 0 | 1 /* 112 p */, |
385 | 0 | 1 /* 113 q */, |
386 | 0 | 1 /* 114 r */, |
387 | 0 | 1 /* 115 s */, |
388 | 0 | 1 /* 116 t */, |
389 | 0 | 1 /* 117 u */, |
390 | 0 | 1 /* 118 v */, |
391 | 0 | 1 /* 119 w */, |
392 | 0 | 1 /* 120 x */, |
393 | 0 | 1 /* 121 y */, |
394 | 0 | 1 /* 122 z */, |
395 | 0 | 0 /* 123 { */, |
396 | 0 | 0 /* 124 | */, |
397 | 0 | 0 /* 125 } */, |
398 | 0 | 1 /* 126 ~ */, |
399 | 0 | 0 /* 127 DEL */ |
400 | 0 | }[(int)c]; |
401 | 0 | } Unexecuted instantiation: msg_parser.c:is_username_char Unexecuted instantiation: parse_uri.c:is_username_char Unexecuted instantiation: parse_to.c:is_username_char Unexecuted instantiation: strcommon.c:is_username_char Unexecuted instantiation: transformations.c:is_username_char Unexecuted instantiation: pvar.c:is_username_char Unexecuted instantiation: parse_ppi.c:is_username_char Unexecuted instantiation: parse_from.c:is_username_char Unexecuted instantiation: core_cmds.c:is_username_char Unexecuted instantiation: fuzz_uri_parser.c:is_username_char |
402 | | |
403 | | |
404 | | static inline int is_username_str(const str *username) |
405 | 0 | { |
406 | 0 | char *p, *end, c; |
407 | 0 |
|
408 | 0 | for (p = username->s, end = p + username->len; p < end; p++) { |
409 | 0 | c = *p; |
410 | 0 |
|
411 | 0 | if (c < 0) |
412 | 0 | goto err; |
413 | 0 |
|
414 | 0 | if (c == '%') { |
415 | 0 | if ((p + 3) > end || !_isxdigit(*(p + 1)) || !_isxdigit(*(p + 2))) |
416 | 0 | goto err; |
417 | 0 | p += 2; |
418 | 0 | } else if (!is_username_char(c)) { |
419 | 0 | goto err; |
420 | 0 | } |
421 | 0 | } |
422 | 0 |
|
423 | 0 | return 1; |
424 | 0 |
|
425 | 0 | err: |
426 | 0 | LM_DBG("invalid character %c[%d] in username <%.*s> on index %d\n", |
427 | 0 | c, c, username->len, username->s, (int)(p - username->s)); |
428 | 0 | return 0; |
429 | 0 | } Unexecuted instantiation: msg_parser.c:is_username_str Unexecuted instantiation: parse_uri.c:is_username_str Unexecuted instantiation: parse_to.c:is_username_str Unexecuted instantiation: strcommon.c:is_username_str Unexecuted instantiation: transformations.c:is_username_str Unexecuted instantiation: pvar.c:is_username_str Unexecuted instantiation: parse_ppi.c:is_username_str Unexecuted instantiation: parse_from.c:is_username_str Unexecuted instantiation: core_cmds.c:is_username_str Unexecuted instantiation: fuzz_uri_parser.c:is_username_str |
430 | | |
431 | | |
432 | | static inline int is_uri_parameter_char(char c) |
433 | 0 | { |
434 | 0 | return (int[]){ |
435 | 0 | 0 /* 0 NUL */, |
436 | 0 | 0 /* 1 SOH */, |
437 | 0 | 0 /* 2 STX */, |
438 | 0 | 0 /* 3 ETX */, |
439 | 0 | 0 /* 4 EOT */, |
440 | 0 | 0 /* 5 ENQ */, |
441 | 0 | 0 /* 6 ACK */, |
442 | 0 | 0 /* 7 BEL */, |
443 | 0 | 0 /* 8 BS */, |
444 | 0 | 0 /* 9 HT */, |
445 | 0 | 0 /* 10 LF */, |
446 | 0 | 0 /* 11 VT */, |
447 | 0 | 0 /* 12 FF */, |
448 | 0 | 0 /* 13 CR */, |
449 | 0 | 0 /* 14 SO */, |
450 | 0 | 0 /* 15 SI */, |
451 | 0 | 0 /* 16 DLE */, |
452 | 0 | 0 /* 17 DC1 */, |
453 | 0 | 0 /* 18 DC2 */, |
454 | 0 | 0 /* 19 DC3 */, |
455 | 0 | 0 /* 20 DC4 */, |
456 | 0 | 0 /* 21 NAK */, |
457 | 0 | 0 /* 22 SYN */, |
458 | 0 | 0 /* 23 ETB */, |
459 | 0 | 0 /* 24 CAN */, |
460 | 0 | 0 /* 25 EM */, |
461 | 0 | 0 /* 26 SUB */, |
462 | 0 | 0 /* 27 ESC */, |
463 | 0 | 0 /* 28 FS */, |
464 | 0 | 0 /* 29 GS */, |
465 | 0 | 0 /* 30 RS */, |
466 | 0 | 0 /* 31 US */, |
467 | 0 | 0 /* 32 */, |
468 | 0 | 1 /* 33 ! */, |
469 | 0 | 0 /* 34 " */, |
470 | 0 | 0 /* 35 # */, |
471 | 0 | 1 /* 36 $ */, |
472 | 0 | 0 /* 37 % */, |
473 | 0 | 1 /* 38 & */, |
474 | 0 | 1 /* 39 ' */, |
475 | 0 | 1 /* 40 ( */, |
476 | 0 | 1 /* 41 ) */, |
477 | 0 | 1 /* 42 * */, |
478 | 0 | 1 /* 43 + */, |
479 | 0 | 0 /* 44 , */, |
480 | 0 | 1 /* 45 - */, |
481 | 0 | 1 /* 46 . */, |
482 | 0 | 1 /* 47 / */, |
483 | 0 | 1 /* 48 0 */, |
484 | 0 | 1 /* 49 1 */, |
485 | 0 | 1 /* 50 2 */, |
486 | 0 | 1 /* 51 3 */, |
487 | 0 | 1 /* 52 4 */, |
488 | 0 | 1 /* 53 5 */, |
489 | 0 | 1 /* 54 6 */, |
490 | 0 | 1 /* 55 7 */, |
491 | 0 | 1 /* 56 8 */, |
492 | 0 | 1 /* 57 9 */, |
493 | 0 | 1 /* 58 : */, |
494 | 0 | 0 /* 59 ; */, |
495 | 0 | 0 /* 60 < */, |
496 | 0 | 0 /* 61 = */, |
497 | 0 | 0 /* 62 > */, |
498 | 0 | 0 /* 63 ? */, |
499 | 0 | 0 /* 64 @ */, |
500 | 0 | 1 /* 65 A */, |
501 | 0 | 1 /* 66 B */, |
502 | 0 | 1 /* 67 C */, |
503 | 0 | 1 /* 68 D */, |
504 | 0 | 1 /* 69 E */, |
505 | 0 | 1 /* 70 F */, |
506 | 0 | 1 /* 71 G */, |
507 | 0 | 1 /* 72 H */, |
508 | 0 | 1 /* 73 I */, |
509 | 0 | 1 /* 74 J */, |
510 | 0 | 1 /* 75 K */, |
511 | 0 | 1 /* 76 L */, |
512 | 0 | 1 /* 77 M */, |
513 | 0 | 1 /* 78 N */, |
514 | 0 | 1 /* 79 O */, |
515 | 0 | 1 /* 80 P */, |
516 | 0 | 1 /* 81 Q */, |
517 | 0 | 1 /* 82 R */, |
518 | 0 | 1 /* 83 S */, |
519 | 0 | 1 /* 84 T */, |
520 | 0 | 1 /* 85 U */, |
521 | 0 | 1 /* 86 V */, |
522 | 0 | 1 /* 87 W */, |
523 | 0 | 1 /* 88 X */, |
524 | 0 | 1 /* 89 Y */, |
525 | 0 | 1 /* 90 Z */, |
526 | 0 | 1 /* 91 [ */, |
527 | 0 | 0 /* 92 \ */, |
528 | 0 | 1 /* 93 ] */, |
529 | 0 | 0 /* 94 ^ */, |
530 | 0 | 1 /* 95 _ */, |
531 | 0 | 0 /* 96 ` */, |
532 | 0 | 1 /* 97 a */, |
533 | 0 | 1 /* 98 b */, |
534 | 0 | 1 /* 99 c */, |
535 | 0 | 1 /* 100 d */, |
536 | 0 | 1 /* 101 e */, |
537 | 0 | 1 /* 102 f */, |
538 | 0 | 1 /* 103 g */, |
539 | 0 | 1 /* 104 h */, |
540 | 0 | 1 /* 105 i */, |
541 | 0 | 1 /* 106 j */, |
542 | 0 | 1 /* 107 k */, |
543 | 0 | 1 /* 108 l */, |
544 | 0 | 1 /* 109 m */, |
545 | 0 | 1 /* 110 n */, |
546 | 0 | 1 /* 111 o */, |
547 | 0 | 1 /* 112 p */, |
548 | 0 | 1 /* 113 q */, |
549 | 0 | 1 /* 114 r */, |
550 | 0 | 1 /* 115 s */, |
551 | 0 | 1 /* 116 t */, |
552 | 0 | 1 /* 117 u */, |
553 | 0 | 1 /* 118 v */, |
554 | 0 | 1 /* 119 w */, |
555 | 0 | 1 /* 120 x */, |
556 | 0 | 1 /* 121 y */, |
557 | 0 | 1 /* 122 z */, |
558 | 0 | 0 /* 123 { */, |
559 | 0 | 0 /* 124 | */, |
560 | 0 | 0 /* 125 } */, |
561 | 0 | 1 /* 126 ~ */, |
562 | 0 | 0 /* 127 DEL */ |
563 | 0 | }[(int)c]; |
564 | 0 | } Unexecuted instantiation: msg_parser.c:is_uri_parameter_char Unexecuted instantiation: parse_uri.c:is_uri_parameter_char Unexecuted instantiation: parse_to.c:is_uri_parameter_char Unexecuted instantiation: strcommon.c:is_uri_parameter_char Unexecuted instantiation: transformations.c:is_uri_parameter_char Unexecuted instantiation: pvar.c:is_uri_parameter_char Unexecuted instantiation: parse_ppi.c:is_uri_parameter_char Unexecuted instantiation: parse_from.c:is_uri_parameter_char Unexecuted instantiation: core_cmds.c:is_uri_parameter_char Unexecuted instantiation: fuzz_uri_parser.c:is_uri_parameter_char |
565 | | |
566 | | |
567 | | static inline int is_uri_parameter_str(const str *uri_param) |
568 | 0 | { |
569 | 0 | char *p, *end, c; |
570 | 0 |
|
571 | 0 | for (p = uri_param->s, end = p + uri_param->len; p < end; p++) { |
572 | 0 | c = *p; |
573 | 0 |
|
574 | 0 | if (c < 0) |
575 | 0 | goto err; |
576 | 0 |
|
577 | 0 | if (c == '%') { |
578 | 0 | if ((p + 3) > end || !_isxdigit(*(p + 1)) || !_isxdigit(*(p + 2))) |
579 | 0 | goto err; |
580 | 0 | p += 2; |
581 | 0 | } else if (!is_uri_parameter_char(c)) { |
582 | 0 | goto err; |
583 | 0 | } |
584 | 0 | } |
585 | 0 |
|
586 | 0 | return 1; |
587 | 0 |
|
588 | 0 | err: |
589 | 0 | LM_DBG("invalid character %c[%d] in uri-parameter <%.*s> on index %d\n", |
590 | 0 | c, c, uri_param->len, uri_param->s, (int)(p - uri_param->s)); |
591 | 0 | return 0; |
592 | 0 | } Unexecuted instantiation: msg_parser.c:is_uri_parameter_str Unexecuted instantiation: parse_uri.c:is_uri_parameter_str Unexecuted instantiation: parse_to.c:is_uri_parameter_str Unexecuted instantiation: strcommon.c:is_uri_parameter_str Unexecuted instantiation: transformations.c:is_uri_parameter_str Unexecuted instantiation: pvar.c:is_uri_parameter_str Unexecuted instantiation: parse_ppi.c:is_uri_parameter_str Unexecuted instantiation: parse_from.c:is_uri_parameter_str Unexecuted instantiation: core_cmds.c:is_uri_parameter_str Unexecuted instantiation: fuzz_uri_parser.c:is_uri_parameter_str |
593 | | |
594 | | #endif /* PARSE_URI_H */ |