forked from openwrt/telephony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openwrt#756 from micmac1/ast-18.11.2
asterisk: bump to 18.11.2
- Loading branch information
Showing
12 changed files
with
2,036 additions
and
267 deletions.
There are no files selected for viewing
653 changes: 653 additions & 0 deletions
653
libs/pjproject/patches/0130-sip_inv-Additional-multipart-support-2919-2920.patch
Large diffs are not rendered by default.
Oops, something went wrong.
116 changes: 116 additions & 0 deletions
116
libs/pjproject/patches/0140-Fix-incorrect-unescaping-of-tokens-during-parsing-29.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
From 3faf1d2b4da553bbaee04f9a13a5d084b381e5fb Mon Sep 17 00:00:00 2001 | ||
From: sauwming <[email protected]> | ||
Date: Tue, 4 Jan 2022 15:28:49 +0800 | ||
Subject: [PATCH] Fix incorrect unescaping of tokens during parsing (#2933) | ||
|
||
--- | ||
pjsip/src/pjsip/sip_parser.c | 29 +++++++++++++++++++++++++---- | ||
pjsip/src/test/msg_test.c | 6 +++--- | ||
2 files changed, 28 insertions(+), 7 deletions(-) | ||
|
||
--- a/pjsip/src/pjsip/sip_parser.c | ||
+++ b/pjsip/src/pjsip/sip_parser.c | ||
@@ -378,17 +378,23 @@ static pj_status_t init_parser() | ||
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); | ||
pj_cis_add_str( &pconst.pjsip_TOKEN_SPEC, TOKEN); | ||
|
||
+ /* Token is allowed to have '%' so we do not need this. */ | ||
+ /* | ||
status = pj_cis_dup(&pconst.pjsip_TOKEN_SPEC_ESC, &pconst.pjsip_TOKEN_SPEC); | ||
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); | ||
pj_cis_del_str(&pconst.pjsip_TOKEN_SPEC_ESC, "%"); | ||
+ */ | ||
|
||
status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC, &pconst.pjsip_TOKEN_SPEC); | ||
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); | ||
pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC, "[:]"); | ||
|
||
+ /* Token is allowed to have '%' */ | ||
+ /* | ||
status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC_ESC, &pconst.pjsip_TOKEN_SPEC_ESC); | ||
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); | ||
pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC_ESC, "[:]"); | ||
+ */ | ||
|
||
status = pj_cis_dup(&pconst.pjsip_HOST_SPEC, &pconst.pjsip_ALNUM_SPEC); | ||
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); | ||
@@ -1210,7 +1216,11 @@ static void parse_param_imp( pj_scanner | ||
unsigned option) | ||
{ | ||
/* pname */ | ||
- parser_get_and_unescape(scanner, pool, spec, esc_spec, pname); | ||
+ if (!esc_spec) { | ||
+ pj_scan_get(scanner, spec, pname); | ||
+ } else { | ||
+ parser_get_and_unescape(scanner, pool, spec, esc_spec, pname); | ||
+ } | ||
|
||
/* init pvalue */ | ||
pvalue->ptr = NULL; | ||
@@ -1240,7 +1250,12 @@ static void parse_param_imp( pj_scanner | ||
// pj_scan_get_until_ch(scanner, ']', pvalue); | ||
// pj_scan_get_char(scanner); | ||
} else if(pj_cis_match(spec, *scanner->curptr)) { | ||
- parser_get_and_unescape(scanner, pool, spec, esc_spec, pvalue); | ||
+ if (!esc_spec) { | ||
+ pj_scan_get(scanner, spec, pvalue); | ||
+ } else { | ||
+ parser_get_and_unescape(scanner, pool, spec, esc_spec, | ||
+ pvalue); | ||
+ } | ||
} | ||
} | ||
} | ||
@@ -1252,7 +1267,10 @@ PJ_DEF(void) pjsip_parse_param_imp(pj_sc | ||
unsigned option) | ||
{ | ||
parse_param_imp(scanner, pool, pname, pvalue, &pconst.pjsip_TOKEN_SPEC, | ||
- &pconst.pjsip_TOKEN_SPEC_ESC, option); | ||
+ // Token does not need to be unescaped. | ||
+ // Refer to PR #2933. | ||
+ // &pconst.pjsip_TOKEN_SPEC_ESC, | ||
+ NULL, option); | ||
} | ||
|
||
|
||
@@ -2168,7 +2186,10 @@ static void int_parse_via_param( pjsip_v | ||
pj_scan_get_char(scanner); | ||
parse_param_imp(scanner, pool, &pname, &pvalue, | ||
&pconst.pjsip_VIA_PARAM_SPEC, | ||
- &pconst.pjsip_VIA_PARAM_SPEC_ESC, | ||
+ // Token does not need to be unescaped. | ||
+ // Refer to PR #2933. | ||
+ // &pconst.pjsip_VIA_PARAM_SPEC_ESC, | ||
+ NULL, | ||
0); | ||
|
||
if (!parser_stricmp(pname, pconst.pjsip_BRANCH_STR) && pvalue.slen) { | ||
--- a/pjsip/src/test/msg_test.c | ||
+++ b/pjsip/src/test/msg_test.c | ||
@@ -953,7 +953,7 @@ static int hdr_test_subject_utf(pjsip_hd | ||
|
||
|
||
#define GENERIC_PARAM "p0=a;p1=\"ab:;cd\";p2=ab%3acd;p3" | ||
-#define GENERIC_PARAM_PARSED "p0=a;p1=\"ab:;cd\";p2=ab:cd;p3" | ||
+#define GENERIC_PARAM_PARSED "p0=a;p1=\"ab:;cd\";p2=ab%3acd;p3" | ||
#define PARAM_CHAR "][/:&+$" | ||
#define SIMPLE_ADDR_SPEC "sip:host" | ||
#define ADDR_SPEC SIMPLE_ADDR_SPEC ";"PARAM_CHAR"="PARAM_CHAR ";p1=\";\"" | ||
@@ -1401,7 +1401,7 @@ static int generic_param_test(pjsip_para | ||
param = param->next; | ||
if (pj_strcmp2(¶m->name, "p2")) | ||
return -956; | ||
- if (pj_strcmp2(¶m->value, "ab:cd")) | ||
+ if (pj_strcmp2(¶m->value, "ab%3acd")) | ||
return -957; | ||
|
||
param = param->next; | ||
@@ -1621,7 +1621,7 @@ static int hdr_test_content_type(pjsip_h | ||
prm = prm->next; | ||
if (prm == &hdr->media.param) return -1960; | ||
if (pj_strcmp2(&prm->name, "p2")) return -1961; | ||
- if (pj_strcmp2(&prm->value, "ab:cd")) return -1962; | ||
+ if (pj_strcmp2(&prm->value, "ab%3acd")) return -1962; | ||
|
||
prm = prm->next; | ||
if (prm == &hdr->media.param) return -1970; |
169 changes: 169 additions & 0 deletions
169
libs/pjproject/patches/0150-Create-generic-pjsip_hdr_find-functions.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
From 7e3dfd8a15fd0f98dbf0e04d2d7a5bded90ee401 Mon Sep 17 00:00:00 2001 | ||
From: George Joseph <[email protected]> | ||
Date: Tue, 11 Jan 2022 09:27:23 -0700 | ||
Subject: [PATCH] Create generic pjsip_hdr_find functions | ||
|
||
pjsip_msg_find_hdr(), pjsip_msg_find_hdr_by_name(), and | ||
pjsip_msg_find_hdr_by_names() require a pjsip_msg to be passed in | ||
so if you need to search a header list that's not in a pjsip_msg, | ||
you have to do it yourself. This commit adds generic versions of | ||
those 3 functions that take in the actual header list head instead | ||
of a pjsip_msg so if you need to search a list of headers in | ||
something like a pjsip_multipart_part, you can do so easily. | ||
--- | ||
pjsip/include/pjsip/sip_msg.h | 53 +++++++++++++++++++++++++++++++++++ | ||
pjsip/src/pjsip/sip_msg.c | 51 +++++++++++++++++++++++---------- | ||
2 files changed, 89 insertions(+), 15 deletions(-) | ||
|
||
--- a/pjsip/include/pjsip/sip_msg.h | ||
+++ b/pjsip/include/pjsip/sip_msg.h | ||
@@ -363,6 +363,59 @@ PJ_DECL(void*) pjsip_hdr_shallow_clone( | ||
PJ_DECL(int) pjsip_hdr_print_on( void *hdr, char *buf, pj_size_t len); | ||
|
||
/** | ||
+ * Find a header in a header list by the header type. | ||
+ * | ||
+ * @param hdr_list The "head" of the header list. | ||
+ * @param type The header type to find. | ||
+ * @param start The first header field where the search should begin. | ||
+ * If NULL is specified, then the search will begin from the | ||
+ * first header, otherwise the search will begin at the | ||
+ * specified header. | ||
+ * | ||
+ * @return The header field, or NULL if no header with the specified | ||
+ * type is found. | ||
+ */ | ||
+PJ_DECL(void*) pjsip_hdr_find( const void *hdr_list, | ||
+ pjsip_hdr_e type, | ||
+ const void *start); | ||
+ | ||
+/** | ||
+ * Find a header in a header list by its name. | ||
+ * | ||
+ * @param hdr_list The "head" of the header list. | ||
+ * @param name The header name to find. | ||
+ * @param start The first header field where the search should begin. | ||
+ * If NULL is specified, then the search will begin from the | ||
+ * first header, otherwise the search will begin at the | ||
+ * specified header. | ||
+ * | ||
+ * @return The header field, or NULL if no header with the specified | ||
+ * type is found. | ||
+ */ | ||
+PJ_DECL(void*) pjsip_hdr_find_by_name( const void *hdr_list, | ||
+ const pj_str_t *name, | ||
+ const void *start); | ||
+ | ||
+/** | ||
+ * Find a header in a header list by its name and short name version. | ||
+ * | ||
+ * @param hdr_list The "head" of the header list. | ||
+ * @param name The header name to find. | ||
+ * @param sname The short name version of the header name. | ||
+ * @param start The first header field where the search should begin. | ||
+ * If NULL is specified, then the search will begin from the | ||
+ * first header, otherwise the search will begin at the | ||
+ * specified header. | ||
+ * | ||
+ * @return The header field, or NULL if no header with the specified | ||
+ * type is found. | ||
+ */ | ||
+PJ_DECL(void*) pjsip_hdr_find_by_names( const void *hdr_list, | ||
+ const pj_str_t *name, | ||
+ const pj_str_t *sname, | ||
+ const void *start); | ||
+ | ||
+/** | ||
* @} | ||
*/ | ||
|
||
--- a/pjsip/src/pjsip/sip_msg.c | ||
+++ b/pjsip/src/pjsip/sip_msg.c | ||
@@ -334,13 +334,13 @@ PJ_DEF(pjsip_msg*) pjsip_msg_clone( pj_p | ||
return dst; | ||
} | ||
|
||
-PJ_DEF(void*) pjsip_msg_find_hdr( const pjsip_msg *msg, | ||
- pjsip_hdr_e hdr_type, const void *start) | ||
+PJ_DEF(void*) pjsip_hdr_find( const void *hdr_list, | ||
+ pjsip_hdr_e hdr_type, const void *start) | ||
{ | ||
- const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=&msg->hdr; | ||
+ const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list; | ||
|
||
if (hdr == NULL) { | ||
- hdr = msg->hdr.next; | ||
+ hdr = end->next; | ||
} | ||
for (; hdr!=end; hdr = hdr->next) { | ||
if (hdr->type == hdr_type) | ||
@@ -349,14 +349,14 @@ PJ_DEF(void*) pjsip_msg_find_hdr( const | ||
return NULL; | ||
} | ||
|
||
-PJ_DEF(void*) pjsip_msg_find_hdr_by_name( const pjsip_msg *msg, | ||
- const pj_str_t *name, | ||
- const void *start) | ||
+PJ_DEF(void*) pjsip_hdr_find_by_name( const void *hdr_list, | ||
+ const pj_str_t *name, | ||
+ const void *start) | ||
{ | ||
- const pjsip_hdr *hdr=(const pjsip_hdr*)start, *end=&msg->hdr; | ||
+ const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list; | ||
|
||
if (hdr == NULL) { | ||
- hdr = msg->hdr.next; | ||
+ hdr = end->next; | ||
} | ||
for (; hdr!=end; hdr = hdr->next) { | ||
if (pj_stricmp(&hdr->name, name) == 0) | ||
@@ -365,15 +365,15 @@ PJ_DEF(void*) pjsip_msg_find_hdr_by_nam | ||
return NULL; | ||
} | ||
|
||
-PJ_DEF(void*) pjsip_msg_find_hdr_by_names( const pjsip_msg *msg, | ||
- const pj_str_t *name, | ||
- const pj_str_t *sname, | ||
- const void *start) | ||
+PJ_DEF(void*) pjsip_hdr_find_by_names( const void *hdr_list, | ||
+ const pj_str_t *name, | ||
+ const pj_str_t *sname, | ||
+ const void *start) | ||
{ | ||
- const pjsip_hdr *hdr=(const pjsip_hdr*)start, *end=&msg->hdr; | ||
+ const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list; | ||
|
||
if (hdr == NULL) { | ||
- hdr = msg->hdr.next; | ||
+ hdr = end->next; | ||
} | ||
for (; hdr!=end; hdr = hdr->next) { | ||
if (pj_stricmp(&hdr->name, name) == 0) | ||
@@ -384,6 +384,27 @@ PJ_DEF(void*) pjsip_msg_find_hdr_by_nam | ||
return NULL; | ||
} | ||
|
||
+PJ_DEF(void*) pjsip_msg_find_hdr( const pjsip_msg *msg, | ||
+ pjsip_hdr_e hdr_type, const void *start) | ||
+{ | ||
+ return pjsip_hdr_find(&msg->hdr, hdr_type, start); | ||
+} | ||
+ | ||
+PJ_DEF(void*) pjsip_msg_find_hdr_by_name( const pjsip_msg *msg, | ||
+ const pj_str_t *name, | ||
+ const void *start) | ||
+{ | ||
+ return pjsip_hdr_find_by_name(&msg->hdr, name, start); | ||
+} | ||
+ | ||
+PJ_DEF(void*) pjsip_msg_find_hdr_by_names( const pjsip_msg *msg, | ||
+ const pj_str_t *name, | ||
+ const pj_str_t *sname, | ||
+ const void *start) | ||
+{ | ||
+ return pjsip_hdr_find_by_names(&msg->hdr, name, sname, start); | ||
+} | ||
+ | ||
PJ_DEF(void*) pjsip_msg_find_remove_hdr( pjsip_msg *msg, | ||
pjsip_hdr_e hdr_type, void *start) | ||
{ |
Oops, something went wrong.