From bce4b2137cd334f3978f52c42e5376ca84021af1 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 22 Aug 2013 08:36:37 +0200 Subject: [PATCH 1/8] Add upstream patch to get src address details of malformed messages. This can help to create fail2ban rules to ban attacks that do not hit our security system. This kind of messages will never reach the config execution. --- debian/patches/series | 1 + ...ddress-details-if-initial-message-pa.patch | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch diff --git a/debian/patches/series b/debian/patches/series index 8ce7a2e1a..943ae5b7f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -8,6 +8,7 @@ upstream/core-xavp-Added-helper-function-to-get-a-list-of-key.patch upstream/app_lua-Added-sr.xavp.get_keys-function.patch upstream/app_lua-Added-sr.xavp.get-function-in-order-to-get-a.patch upstream/0001-core-do-not-repeat-key-names-on-xavp_get_list_key_na.patch +upstream/0001-core-print-src-address-details-if-initial-message-pa.patch upstream/debug/0002-core-updated-dprint-api-to-enable-support-for-debug-.patch upstream/debug/0003-debugger-option-to-set-debug-level-per-module.patch upstream/debug/core-use-pointer-to-pv_spec_t-on-lvalue-union.-Use-p.patch diff --git a/debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch b/debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch new file mode 100644 index 000000000..ae3d4355a --- /dev/null +++ b/debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch @@ -0,0 +1,29 @@ +From 3ccf4b43e81bd2654cb306a3c2cc21b97cb51f62 Mon Sep 17 00:00:00 2001 +From: Daniel-Constantin Mierla +Date: Thu, 22 Aug 2013 00:14:53 +0200 +Subject: [PATCH] core: print src address details if initial message parsing + fails + +- reported by Juha Heinanen +--- + receive.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/receive.c b/receive.c +index a4018ff..6b5740f 100644 +--- a/receive.c ++++ b/receive.c +@@ -143,7 +143,9 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) + + if (parse_msg(buf,len, msg)!=0){ + LOG(cfg_get(core, core_cfg, corelog), +- "ERROR: receive_msg: parse_msg failed\n"); ++ "core parsing of SIP message failed (%s:%d/%d)\n", ++ ip_addr2a(&msg->rcv.src_ip), (int)msg->rcv.src_port, ++ (int)msg->rcv.proto); + goto error02; + } + DBG("After parse_msg...\n"); +-- +1.7.10.4 + From 8098f4bfdf573032f79374d3d4b231920517257c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 28 Aug 2013 14:50:54 -0400 Subject: [PATCH 2/8] fix possible segfault in rtpproxy-ng --- debian/patches/sipwise/rtproxy-ng.patch | 37 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/debian/patches/sipwise/rtproxy-ng.patch b/debian/patches/sipwise/rtproxy-ng.patch index 37f2a92fb..167bdfd7b 100644 --- a/debian/patches/sipwise/rtproxy-ng.patch +++ b/debian/patches/sipwise/rtproxy-ng.patch @@ -677,7 +677,7 @@ + http://sip-router.org/tracker. --- /dev/null +++ b/modules/rtpproxy-ng/bencode.c -@@ -0,0 +1,701 @@ +@@ -0,0 +1,703 @@ +#include "bencode.h" +#include +#include @@ -780,6 +780,8 @@ + struct __bencode_buffer_piece *piece; + void *ret; + ++ if (!buf) ++ return NULL; + if (buf->error) + return NULL; + @@ -1381,7 +1383,7 @@ +} --- /dev/null +++ b/modules/rtpproxy-ng/bencode.h -@@ -0,0 +1,521 @@ +@@ -0,0 +1,530 @@ +#ifndef _BENCODE_H_ +#define _BENCODE_H_ + @@ -1472,6 +1474,9 @@ + * object is destroyed, the specified function will be called on this pointer. */ +void bencode_buffer_destroy_add(bencode_buffer_t *buf, free_func_t, void *); + ++/* Returns the buffer associated with an item, or NULL if pointer given is NULL */ ++static inline bencode_buffer_t *bencode_item_buffer(bencode_item_t *); ++ + + + @@ -1728,6 +1733,12 @@ + +/**************************/ + ++static inline bencode_buffer_t *bencode_item_buffer(bencode_item_t *i) { ++ if (!i) ++ return NULL; ++ return i->buffer; ++} ++ +static inline bencode_item_t *bencode_string(bencode_buffer_t *buf, const char *s) { + return bencode_string_len(buf, s, strlen(s)); +} @@ -1753,49 +1764,49 @@ +static inline bencode_item_t *bencode_dictionary_add_string(bencode_item_t *dict, const char *key, const char *val) { + if (!val) + return NULL; -+ return bencode_dictionary_add(dict, key, bencode_string(dict->buffer, val)); ++ return bencode_dictionary_add(dict, key, bencode_string(bencode_item_buffer(dict), val)); +} + +static inline bencode_item_t *bencode_dictionary_add_string_dup(bencode_item_t *dict, const char *key, const char *val) { + if (!val) + return NULL; -+ return bencode_dictionary_add(dict, key, bencode_string_dup(dict->buffer, val)); ++ return bencode_dictionary_add(dict, key, bencode_string_dup(bencode_item_buffer(dict), val)); +} + +static inline bencode_item_t *bencode_dictionary_add_str(bencode_item_t *dict, const char *key, const str *val) { + if (!val) + return NULL; -+ return bencode_dictionary_add(dict, key, bencode_str(dict->buffer, val)); ++ return bencode_dictionary_add(dict, key, bencode_str(bencode_item_buffer(dict), val)); +} + +static inline bencode_item_t *bencode_dictionary_add_str_dup(bencode_item_t *dict, const char *key, const str *val) { + if (!val) + return NULL; -+ return bencode_dictionary_add(dict, key, bencode_str_dup(dict->buffer, val)); ++ return bencode_dictionary_add(dict, key, bencode_str_dup(bencode_item_buffer(dict), val)); +} + +static inline bencode_item_t *bencode_dictionary_add_integer(bencode_item_t *dict, const char *key, long long int val) { -+ return bencode_dictionary_add(dict, key, bencode_integer(dict->buffer, val)); ++ return bencode_dictionary_add(dict, key, bencode_integer(bencode_item_buffer(dict), val)); +} + +static inline bencode_item_t *bencode_dictionary_add_dictionary(bencode_item_t *dict, const char *key) { -+ return bencode_dictionary_add(dict, key, bencode_dictionary(dict->buffer)); ++ return bencode_dictionary_add(dict, key, bencode_dictionary(bencode_item_buffer(dict))); +} + +static inline bencode_item_t *bencode_dictionary_add_list(bencode_item_t *dict, const char *key) { -+ return bencode_dictionary_add(dict, key, bencode_list(dict->buffer)); ++ return bencode_dictionary_add(dict, key, bencode_list(bencode_item_buffer(dict))); +} + +static inline bencode_item_t *bencode_list_add_string(bencode_item_t *list, const char *s) { -+ return bencode_list_add(list, bencode_string(list->buffer, s)); ++ return bencode_list_add(list, bencode_string(bencode_item_buffer(list), s)); +} + +static inline bencode_item_t *bencode_list_add_list(bencode_item_t *list) { -+ return bencode_list_add(list, bencode_list(list->buffer)); ++ return bencode_list_add(list, bencode_list(bencode_item_buffer(list))); +} + +static inline bencode_item_t *bencode_list_add_dictionary(bencode_item_t *list) { -+ return bencode_list_add(list, bencode_dictionary(list->buffer)); ++ return bencode_list_add(list, bencode_dictionary(bencode_item_buffer(list))); +} + +static inline bencode_item_t *bencode_dictionary_get(bencode_item_t *dict, const char *key) { @@ -1899,7 +1910,7 @@ +static inline bencode_item_t *bencode_dictionary_add_iovec(bencode_item_t *dict, const char *key, + const struct iovec *iov, int iov_cnt, int str_len) +{ -+ return bencode_dictionary_add(dict, key, bencode_string_iovec(dict->buffer, iov, iov_cnt, str_len)); ++ return bencode_dictionary_add(dict, key, bencode_string_iovec(bencode_item_buffer(dict), iov, iov_cnt, str_len)); +} + +#endif From f15dbc9b1a97a68a2227d2b58484ff9a65e8c1c3 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Mon, 9 Sep 2013 17:04:13 +0200 Subject: [PATCH 3/8] fix get_redirects core dump ( Closes: FS#337 ) --- debian/patches/series | 1 + ..._redirect-check-reason-value-before-.patch | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 debian/patches/sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch diff --git a/debian/patches/series b/debian/patches/series index 943ae5b7f..a88e7ae5a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -38,3 +38,4 @@ sipwise/path_second_parameter.patch sipwise/modules-usrloc-use-6th-param-to-set-the-contact-path.patch sipwise/utils-kamctl-Add-contact-path-parameter.patch sipwise/url-safe_base64.patch +sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch diff --git a/debian/patches/sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch b/debian/patches/sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch new file mode 100644 index 000000000..a6ebd6f96 --- /dev/null +++ b/debian/patches/sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch @@ -0,0 +1,35 @@ +From abf0026782c0ba4643feb25ded022e8c12725584 Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Mon, 9 Sep 2013 16:52:47 +0200 +Subject: [PATCH] uac_redirect: get_redirect() check reason value before using + it. + +This fix a core dump when get_redirects() config fuction is called with just +the one parameter. +--- + modules/uac_redirect/rd_funcs.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/modules/uac_redirect/rd_funcs.c b/modules/uac_redirect/rd_funcs.c +index ca34e0c..aa8dbd0 100644 +--- a/modules/uac_redirect/rd_funcs.c ++++ b/modules/uac_redirect/rd_funcs.c +@@ -96,9 +96,12 @@ int get_redirect( struct sip_msg *msg , int maxt, int maxb, + } + if (max==0) + continue; +- /* put the response code into the acc_param reason struct */ +- reason->code = t->uac[i].last_received; +- reason->code_s.s = int2bstr((unsigned long)reason->code, code_buf, &reason->code_s.len); ++ if(reason!=NULL) ++ { ++ /* put the response code into the acc_param reason struct */ ++ reason->code = t->uac[i].last_received; ++ reason->code_s.s = int2bstr((unsigned long)reason->code, code_buf, &reason->code_s.len); ++ } + /* get the contact from it */ + n = shmcontact2dset( msg, t->uac[i].reply, max, reason, bflags); + if ( n<0 ) { +-- +1.7.10.4 + From 9fabbf154aa7679edb0536a812621baae5087e93 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 10 Sep 2013 09:28:52 +0200 Subject: [PATCH 4/8] uac_redirect patch merged upstream. Will be included on next 4.0 series --- debian/patches/series | 2 +- .../uac_redirect-get_redirect-check-reason-value-before-.patch | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename debian/patches/{sipwise => upstream}/uac_redirect-get_redirect-check-reason-value-before-.patch (100%) diff --git a/debian/patches/series b/debian/patches/series index a88e7ae5a..67dd3e990 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -21,6 +21,7 @@ upstream/debug/0001-modules-debugger-trace-msg-out.patch upstream/debug/modules-debugger-add-dbg_pv_dump-config-function.patch upstream/debug/reset_msgid.patch upstream/websocket.patch +upstream/uac_redirect-get_redirect-check-reason-value-before-.patch no_lib64_on_64_bits.patch no_INSTALL_file.patch fix_export.patch @@ -38,4 +39,3 @@ sipwise/path_second_parameter.patch sipwise/modules-usrloc-use-6th-param-to-set-the-contact-path.patch sipwise/utils-kamctl-Add-contact-path-parameter.patch sipwise/url-safe_base64.patch -sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch diff --git a/debian/patches/sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch b/debian/patches/upstream/uac_redirect-get_redirect-check-reason-value-before-.patch similarity index 100% rename from debian/patches/sipwise/uac_redirect-get_redirect-check-reason-value-before-.patch rename to debian/patches/upstream/uac_redirect-get_redirect-check-reason-value-before-.patch From c2882c9181ca9d82a20f84b4095cd16ffda3c431 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 10 Sep 2013 12:50:53 +0200 Subject: [PATCH 5/8] update changelog (cherry picked from commit 5f3d0317de69bc19126fe8ff9246d2290da33ef9) --- debian/changelog | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/debian/changelog b/debian/changelog index d591f42cd..d651389cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +ngcp-kamailio (4.0.3-2) unstable; urgency=low + + [ Victor Seva ] + * [442c46a] fix get_redirects core dump ( Closes: FS#337 ) (cherry picked from commit f15dbc9b1a97a68a2227d2b58484ff9a65e8c1c3) + * [385bfc3] uac_redirect patch merged upstream. Will be included on next 4.0 series (cherry picked from commit 9fabbf154aa7679edb0536a812621baae5087e93) + + [ Richard Fuchs ] + * [c8d7ab8] fix possible segfault in rtpproxy-ng (cherry picked from commit 8098f4bfdf573032f79374d3d4b231920517257c) + + -- Victor Seva Tue, 10 Sep 2013 12:49:51 +0200 + ngcp-kamailio (4.0.3-1) unstable; urgency=low * New upstream version. From 93233e1422fb5c9fdd8340c08834bc879a24ac6d Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 17 Sep 2013 12:27:43 +0200 Subject: [PATCH 6/8] Add patches from upstream for app_lua sr.xavp.get function --- debian/patches/series | 2 + ...added-param-to-sr.xavp.get-to-choose.patch | 137 ++++++++++++++++++ ...fix-sr.xavp.get.-Get-all-the-values-.patch | 122 ++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 debian/patches/upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch create mode 100644 debian/patches/upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch diff --git a/debian/patches/series b/debian/patches/series index 67dd3e990..114f152f3 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -8,6 +8,8 @@ upstream/core-xavp-Added-helper-function-to-get-a-list-of-key.patch upstream/app_lua-Added-sr.xavp.get_keys-function.patch upstream/app_lua-Added-sr.xavp.get-function-in-order-to-get-a.patch upstream/0001-core-do-not-repeat-key-names-on-xavp_get_list_key_na.patch +upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch +upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch upstream/0001-core-print-src-address-details-if-initial-message-pa.patch upstream/debug/0002-core-updated-dprint-api-to-enable-support-for-debug-.patch upstream/debug/0003-debugger-option-to-set-debug-level-per-module.patch diff --git a/debian/patches/upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch b/debian/patches/upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch new file mode 100644 index 000000000..40f7d372c --- /dev/null +++ b/debian/patches/upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch @@ -0,0 +1,137 @@ +From 8cd7a48479594052b6b6e70d48946e8963e1625d Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Tue, 9 Jul 2013 17:50:06 +0200 +Subject: [PATCH] modules/app_lua: added param to sr.xavp.get to choose + between all the values (default) or just the first ones. + +--- + modules/app_lua/app_lua_sr.c | 88 ++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 81 insertions(+), 7 deletions(-) + +diff --git a/modules/app_lua/app_lua_sr.c b/modules/app_lua/app_lua_sr.c +index 4075ef8..c5229f4 100644 +--- a/modules/app_lua/app_lua_sr.c ++++ b/modules/app_lua/app_lua_sr.c +@@ -1237,6 +1237,57 @@ static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { + return 1; + } + ++ /** ++ * creates and push a table to the lua stack with ++ * only the firsts elements of the xavp ++ */ ++static int lua_sr_push_xavp_table_simple(lua_State *L, sr_xavp_t *xavp) { ++ lua_Number i = 1; ++ sr_xavp_t *avp = NULL; ++ ++ if(xavp->val.type!=SR_XTYPE_XAVP){ ++ LM_ERR("%s not xavp?\n", xavp->name.s); ++ return 0; ++ } ++ avp = xavp->val.v.xavp; ++ ++ lua_newtable(L); ++ while(avp!=NULL){ ++ switch(avp->val.type) { ++ case SR_XTYPE_NULL: ++ lua_pushnil(L); ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ case SR_XTYPE_INT: ++ i = avp->val.v.i; ++ lua_pushnumber(L, i); ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ case SR_XTYPE_STR: ++ lua_pushlstring(L, avp->val.v.s.s, avp->val.v.s.len); ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ case SR_XTYPE_TIME: ++ case SR_XTYPE_LONG: ++ case SR_XTYPE_LLONG: ++ case SR_XTYPE_DATA: ++ lua_pushnil(L); ++ lua_setfield(L, -2, avp->name.s); ++ LM_WARN("XAVP type:%d value not supported\n", avp->val.type); ++ break; ++ case SR_XTYPE_XAVP: ++ if(!lua_sr_push_xavp_table(L,avp->val.v.xavp)){ ++ LM_ERR("xavp:%.*s subtable error. Nil value added\n", avp->name.len, avp->name.s); ++ lua_pushnil(L); ++ } ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ } ++ avp = avp->next; ++ } ++ return 1; ++} ++ + /** + * puts a table with content of a xavp + */ +@@ -1246,23 +1297,38 @@ static int lua_sr_xavp_get(lua_State *L) + int indx = 0; + sr_lua_env_t *env_L; + sr_xavp_t *avp; ++ int num_param = 0; ++ int param = -1; ++ int simple_flag = 0; + + env_L = sr_lua_env_get(); +- +- if(lua_gettop(L)<2) ++ num_param = lua_gettop(L); ++ if(num_param<2 && num_param>3) + { +- LM_ERR("to few parameters [%d]\n",lua_gettop(L)); ++ LM_ERR("wrong number of parameters [%d]\n", num_param); + return 0; + } + +- if(!lua_isnumber(L, -1)) ++ if(num_param==3) ++ { ++ if(!lua_isnumber(L, param)) ++ { ++ LM_ERR("invalid int parameter\n"); ++ return 0; ++ } ++ simple_flag = lua_tointeger(L, param); ++ param = param - 1; ++ } ++ ++ if(!lua_isnumber(L, param)) + { + LM_ERR("invalid int parameter\n"); + return 0; + } +- indx = lua_tointeger(L, -1); ++ indx = lua_tointeger(L, param); ++ param = param - 1; + +- xavp_name.s = (char*)lua_tostring(L, -2); ++ xavp_name.s = (char*)lua_tostring(L, param); + if(xavp_name.s==NULL || env_L->msg==NULL) + return 0; + xavp_name.len = strlen(xavp_name.s); +@@ -1273,7 +1339,15 @@ static int lua_sr_xavp_get(lua_State *L) + lua_pushnil(L); + return 1; + } +- lua_sr_push_xavp_table(L, avp); ++ ++ if (simple_flag != 0) ++ { ++ lua_sr_push_xavp_table_simple(L, avp); ++ } ++ else ++ { ++ lua_sr_push_xavp_table(L, avp); ++ } + return 1; + } + +-- +1.7.10.4 + diff --git a/debian/patches/upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch b/debian/patches/upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch new file mode 100644 index 000000000..64c17ff4c --- /dev/null +++ b/debian/patches/upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch @@ -0,0 +1,122 @@ +From 4a79fcdd9965c6c3195601baeb82d489d970aa12 Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Tue, 9 Jul 2013 15:55:35 +0200 +Subject: [PATCH] modules/app_lua: fix sr.xavp.get. Get all the values not + only the first one. + +--- + modules/app_lua/app_lua_sr.c | 65 ++++++++++++++++++++++++++++++++---------- + 1 file changed, 50 insertions(+), 15 deletions(-) + +diff --git a/modules/app_lua/app_lua_sr.c b/modules/app_lua/app_lua_sr.c +index 93b89b8..4075ef8 100644 +--- a/modules/app_lua/app_lua_sr.c ++++ b/modules/app_lua/app_lua_sr.c +@@ -1151,42 +1151,40 @@ static int lua_sr_push_str_list_table(lua_State *L, struct str_list *list) { + return 1; + } + ++static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp); ++ + /** +- * creates and push a table to the lua stack with +- * the elements of the xavp ++ * creates and push a table for the key name in xavp + */ +-static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { ++static void lua_sr_push_xavp_name_table(lua_State *L, sr_xavp_t *xavp, str name) { + lua_Number i = 1; +- sr_xavp_t *avp = NULL; ++ lua_Number elem = 1; ++ sr_xavp_t *avp = xavp; + +- if(xavp->val.type!=SR_XTYPE_XAVP){ +- LM_ERR("%s not xavp?\n", xavp->name.s); +- return 0; ++ while(avp!=NULL&&!STR_EQ(avp->name,name)) ++ { ++ avp = avp->next; + } +- avp = xavp->val.v.xavp; +- + lua_newtable(L); ++ + while(avp!=NULL){ ++ lua_pushnumber(L, elem); + switch(avp->val.type) { + case SR_XTYPE_NULL: + lua_pushnil(L); +- lua_setfield(L, -2, avp->name.s); + break; + case SR_XTYPE_INT: + i = avp->val.v.i; + lua_pushnumber(L, i); +- lua_setfield(L, -2, avp->name.s); + break; + case SR_XTYPE_STR: + lua_pushlstring(L, avp->val.v.s.s, avp->val.v.s.len); +- lua_setfield(L, -2, avp->name.s); + break; + case SR_XTYPE_TIME: + case SR_XTYPE_LONG: + case SR_XTYPE_LLONG: + case SR_XTYPE_DATA: + lua_pushnil(L); +- lua_setfield(L, -2, avp->name.s); + LM_WARN("XAVP type:%d value not supported\n", avp->val.type); + break; + case SR_XTYPE_XAVP: +@@ -1194,11 +1192,48 @@ static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { + LM_ERR("xavp:%.*s subtable error. Nil value added\n", avp->name.len, avp->name.s); + lua_pushnil(L); + } +- lua_setfield(L, -2, avp->name.s); ++ break; ++ default: ++ LM_ERR("xavp:%.*s unknown type: %d. Nil value added\n", ++ avp->name.len, avp->name.s, avp->val.type); ++ lua_pushnil(L); + break; + } +- avp = avp->next; ++ lua_rawset(L, -3); ++ elem = elem + 1; ++ avp = xavp_get_next(avp); ++ } ++ lua_setfield(L, -2, name.s); ++} ++ ++/** ++ * creates and push a table to the lua stack with ++ * the elements of the xavp ++ */ ++static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { ++ sr_xavp_t *avp = NULL; ++ struct str_list *keys; ++ struct str_list *k; ++ ++ if(xavp->val.type!=SR_XTYPE_XAVP){ ++ LM_ERR("%s not xavp?\n", xavp->name.s); ++ return 0; + } ++ avp = xavp->val.v.xavp; ++ keys = xavp_get_list_key_names(xavp); ++ ++ lua_newtable(L); ++ if(keys!=NULL) ++ { ++ do ++ { ++ lua_sr_push_xavp_name_table(L, avp, keys->s); ++ k = keys; ++ keys = keys->next; ++ pkg_free(k); ++ }while(keys!=NULL); ++ } ++ + return 1; + } + +-- +1.7.10.4 + From bd57b582cadb24847dbef8d6c754d581195e3dbd Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 17 Sep 2013 12:30:06 +0200 Subject: [PATCH 7/8] remove unused patch --- debian/patches/series | 1 - ...ddress-details-if-initial-message-pa.patch | 29 ------------------- 2 files changed, 30 deletions(-) delete mode 100644 debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch diff --git a/debian/patches/series b/debian/patches/series index 114f152f3..d95af0bd2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -10,7 +10,6 @@ upstream/app_lua-Added-sr.xavp.get-function-in-order-to-get-a.patch upstream/0001-core-do-not-repeat-key-names-on-xavp_get_list_key_na.patch upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch -upstream/0001-core-print-src-address-details-if-initial-message-pa.patch upstream/debug/0002-core-updated-dprint-api-to-enable-support-for-debug-.patch upstream/debug/0003-debugger-option-to-set-debug-level-per-module.patch upstream/debug/core-use-pointer-to-pv_spec_t-on-lvalue-union.-Use-p.patch diff --git a/debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch b/debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch deleted file mode 100644 index ae3d4355a..000000000 --- a/debian/patches/upstream/0001-core-print-src-address-details-if-initial-message-pa.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 3ccf4b43e81bd2654cb306a3c2cc21b97cb51f62 Mon Sep 17 00:00:00 2001 -From: Daniel-Constantin Mierla -Date: Thu, 22 Aug 2013 00:14:53 +0200 -Subject: [PATCH] core: print src address details if initial message parsing - fails - -- reported by Juha Heinanen ---- - receive.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/receive.c b/receive.c -index a4018ff..6b5740f 100644 ---- a/receive.c -+++ b/receive.c -@@ -143,7 +143,9 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) - - if (parse_msg(buf,len, msg)!=0){ - LOG(cfg_get(core, core_cfg, corelog), -- "ERROR: receive_msg: parse_msg failed\n"); -+ "core parsing of SIP message failed (%s:%d/%d)\n", -+ ip_addr2a(&msg->rcv.src_ip), (int)msg->rcv.src_port, -+ (int)msg->rcv.proto); - goto error02; - } - DBG("After parse_msg...\n"); --- -1.7.10.4 - From 1d87c5b500e2a6de2671a6bb17522329184cdd7b Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 17 Sep 2013 16:42:21 +0200 Subject: [PATCH 8/8] update debian/changelog --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index d651389cd..971b22b7a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +ngcp-kamailio (4.0.3-3) unstable; urgency=low + + [ Victor Seva ] + * [93233e1] Add patches from upstream for app_lua sr.xavp.get function + * [bd57b58] remove unused patch + + -- Victor Seva Tue, 17 Sep 2013 16:41:05 +0200 + ngcp-kamailio (4.0.3-2) unstable; urgency=low [ Victor Seva ]