THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A new Flyspray task has been opened. Details are below.
User who did this - Hugh Waite (hugh.waite)
Attached to Project - sip-router
Summary - Caching $hdr psuedo-variables causes a error when called from LUA
Task Type - Bug Report
Category - Modules kamailio
Status - Unconfirmed
Assigned To -
Operating System - All
Severity - High
Priority - Normal
Reported Version - Development
Due in Version - Undecided
Due Date - Undecided
Details - We have been using the sr.pv.get() LUA function to extract custom SIP headers, but this has inconsistant results.
I have tracked this back to a bug in the pv module. However, I am not familiar enough with the pv_cache/pv_spec structure to know how to fix this.
In modules_k/pv/pv_core.c:pv_parse_hdr_name() the name of a header to look up is parsed and stored in the pv_spec_t structure. If this is an 'unknown' header, the string pointer is stored in the sructure (line 2487).
2478 sp->pvp.pvn.type = PV_NAME_INTSTR;
2479 if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T)
2480 {
2481 LM_DBG("using hdr type (%d) instead of <%.*s>\n",
2482 hdr.type, in->len, in->s);
2483 sp->pvp.pvn.u.isname.type = 0;
2484 sp->pvp.pvn.u.isname.name.n = hdr.type;
2485 } else {
2486 sp->pvp.pvn.u.isname.type = AVP_NAME_STR;
2487 sp->pvp.pvn.u.isname.name.s = *in; <-------
2488 }
2489 return 0;
2490 error:
2491 return -1;
2492 }
If this has been called from LUA (modules/app_lua/app_lua_sr.c:sr_lua_pv_get():895) this string is part of the lua environment which goes out of scope - causing a problem.
883 pvn.s = (char*)lua_tostring(L, -1);
884 if(pvn.s==NULL || env_L->msg==NULL)
885 return 0;
886
887 pvn.len = strlen(pvn.s);
888 LM_DBG("pv get: %s\n", pvn.s);
889 pl = pv_locate_name(&pvn);
890 if(pl != pvn.len)
891 {
892 LM_ERR("invalid pv [%s] (%d/%d)\n", pvn.s, pl, pvn.len);
893 return 0;
894 }
895 pvs = pv_cache_get(&pvn); <------------- Local variable passed in
896 if(pvs==NULL)
897 {
898 LM_ERR("cannot get pv spec for [%s]\n", pvn.s);
899 return 0;
900 }
When the pv cache structure is created, memory is allocated to duplicate the PV name(pvapi.c:269). Is it safe to pass the newly allocated string into the parse_pv_spec function?
For example: (this is modified from the trunk version)
257 pv_spec_t* pv_cache_add(str *name)
258 {
259 pv_cache_t *pvn;
260 unsigned int pvid;
261 char *p;
262
263 if(_pv_cache_set==0)
264 {
265 LM_DBG("PV cache not initialized, doing it now\n");
266 pv_init_cache();
267 }
268 pvid = get_hash1_raw(name->s, name->len);
269 pvn = (pv_cache_t*)pkg_malloc(sizeof(pv_cache_t) + name->len + 1);
270 if(pvn==0)
271 {
272 LM_ERR("no more memory\n");
273 return NULL;
274 }
275 memset(pvn, 0, sizeof(pv_cache_t) + name->len + 1); <------- Note: There is a separate initialisation bug on this line. It uses sizeof(pv_item_t) in trunk!
276 pvn->pvname.len = name->len;
277 pvn->pvname.s = (char*)pvn + sizeof(pv_cache_t);
278 memcpy(pvn->pvname.s, name->s, name->len);
279 p = pv_parse_spec(&pvn->pvname, &pvn->spec); <------- Is this safe?
280
281 if(p==NULL)
282 {
283 pkg_free(pvn);
284 return NULL;
285 }
286 pvn->pvid = pvid;
287 pvn->next = _pv_cache[pvid%PV_CACHE_SIZE];
288 _pv_cache[pvid%PV_CACHE_SIZE] = pvn;
289
290 LM_DBG("pvar [%.*s] added in cache\n", name->len, name->s);
291 return &pvn->spec;
292 }
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=252
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
Module: sip-router
Branch: master
Commit: c93d2d1b290c030f969ce1f62f106059226457ea
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c93d2d1…
Author: Olle E. Johansson <oej(a)edvina.net>
Committer: Olle E. Johansson <oej(a)edvina.net>
Date: Wed Oct 24 11:47:41 2012 +0200
Merge branch 'master' of ssh://git.sip-router.org/sip-router
I don't really know what this means and why this commit happens...
* 'master' of ssh://git.sip-router.org/sip-router:
.gitignore: added few more patterns to ignore
pkg/kamailio/rpm: specs updated for rename of sercmd to kamcmd
sercmd: added basic man page
sercmd: builds and installs as kamcmd when FLAVOUR=kamailio
Makefile.utils: new target to install manpage for util tools
kamctl: replaced openser with kamailio in variable and function names
core: print modparam type id in log when parameter not found
modules/rtpproxy: added 't' flag to rtpproxy_destroy and force_rtp_proxy - Added new flag 't' to rtpproxy_destroy function that makes it possible do delete whole call even when To tag is present in request/reply. In force_rtp_proxy the flag is ignored.
---
Module: sip-router
Branch: master
Commit: c4b3b04eb59de8b1b72675decfa06ff3cb779934
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c4b3b04…
Author: Olle E. Johansson <oej(a)edvina.net>
Committer: Olle E. Johansson <oej(a)edvina.net>
Date: Sun Oct 21 20:09:07 2012 +0200
mtree Documentation fixes
---
modules/mtree/README | 18 +++++++++---------
modules/mtree/doc/mtree_admin.xml | 18 +++++++++++++-----
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/modules/mtree/README b/modules/mtree/README
index 8d76777..3be2e53 100644
--- a/modules/mtree/README
+++ b/modules/mtree/README
@@ -164,8 +164,8 @@ modparam("mtree", "db_url", "dbdriver://username:password@dbhost/dbname")
3.2. db_table (string)
- Name of DB table where data for trees is store. It is ignored if a
- 'mtree' parameter is defined.
+ Name of database table where data for trees is stored. It is ignored if
+ a 'mtree' parameter is defined.
Default value is "mtrees".
@@ -242,7 +242,7 @@ modparam("mtree", "char_list", "0123456789*+")
3.9. pv_value (string)
- The PV spec where to store the matched value. It can be any writtable
+ The PV spec where to store the matched value. It can be any writable
PV.
Default value is "$avp(s:tvalue)".
@@ -305,12 +305,12 @@ modparam("mtree", "mt_allow_duplicates", 1)
4.1. mt_match(mtree, pv, mode)
Match 'pv' value against 'mtree'. If 'mtree' type is 0 or 2 and value
- of 'mode' is NOT 2, sets a value of longest matching prefix to pseudo
- variable specified by pv_value parameter. If 'mtree' type is 0 or 2 and
- value of 'mode' is 2, sets values of all matching prefixes to avp
- specified by pv_values parameter so that a value of longest matching
- prefix is in avp index 0. Parameter 'mode' can be an integer constant
- or a pseudo variable with integer value.
+ of 'mode' is NOT 2, sets a value of the longest matching prefix to
+ pseudo variable specified by pv_value parameter. If 'mtree' type is 0
+ or 2 and value of 'mode' is 2, sets values of all matching prefixes to
+ avp specified by pv_values parameter so that a value of longest
+ matching prefix is in avp index 0. Parameter 'mode' can be an integer
+ constant or a pseudo variable with integer value.
Example 1.14. mt_match usage
...
diff --git a/modules/mtree/doc/mtree_admin.xml b/modules/mtree/doc/mtree_admin.xml
index a58429c..8558ccd 100644
--- a/modules/mtree/doc/mtree_admin.xml
+++ b/modules/mtree/doc/mtree_admin.xml
@@ -76,7 +76,7 @@ modparam("mtree", "db_url", "&exampledb;")
<section>
<title><varname>db_table</varname> (string)</title>
<para>
- Name of DB table where data for trees is store. It is ignored if a
+ Name of database table where data for trees is stored. It is ignored if a
'mtree' parameter is defined.
</para>
<para>
@@ -218,7 +218,7 @@ modparam("mtree", "char_list", "0123456789*+")
<title><varname>pv_value</varname> (string)</title>
<para>
The PV spec where to store the matched value. It can be any
- writtable PV.
+ writable PV.
</para>
<para>
<emphasis>
@@ -238,7 +238,8 @@ modparam("mtree", "pv_value", "$var(mtval)")
<section>
<title><varname>pv_values</varname> (string)</title>
<para>
- The PV spec where to store the matched values when mtree is of type 0 or 2 and mode of mt_match() call has value 2. It can be any AVP.
+ The PV spec where to store the matched values when mtree is of type
+ 0 or 2 and mode of mt_match() call has value 2. It can be any AVP.
</para>
<para>
<emphasis>
@@ -258,7 +259,8 @@ modparam("mtree", "pv_values", "$avp(mtvals)")
<section>
<title><varname>mt_tree_type</varname> (integer)</title>
<para>
- Default payload type for trees data stored in 'db_table'. Documented values are 0 for string payloads and 2 for integer payloads.
+ Default payload type for trees data stored in 'db_table'. Documented
+ values are 0 for string payloads and 2 for integer payloads.
</para>
<para>
<emphasis>
@@ -324,7 +326,13 @@ modparam("mtree", "mt_allow_duplicates", 1)
<function moreinfo="none">mt_match(mtree, pv, mode)</function>
</title>
<para>
- Match 'pv' value against 'mtree'. If 'mtree' type is 0 or 2 and value of 'mode' is NOT 2, sets a value of longest matching prefix to pseudo variable specified by pv_value parameter. If 'mtree' type is 0 or 2 and value of 'mode' is 2, sets values of all matching prefixes to avp specified by pv_values parameter so that a value of longest matching prefix is in avp index 0. Parameter 'mode' can be an integer constant or a pseudo variable with integer value.
+ Match 'pv' value against 'mtree'. If 'mtree' type is 0 or 2 and value
+ of 'mode' is NOT 2, sets a value of the longest matching prefix to
+ pseudo variable specified by pv_value parameter. If 'mtree' type is
+ 0 or 2 and value of 'mode' is 2, sets values of all matching prefixes
+ to avp specified by pv_values parameter so that a value of longest
+ matching prefix is in avp index 0. Parameter 'mode' can be an integer
+ constant or a pseudo variable with integer value.
</para>
<example>
<title><function>mt_match</function> usage</title>
Hello,
short note to let everyone know that sercmd tool compiles and installs
as kamcmd for flavour kamailio as of today in the master git branch.
There was a conflict when trying to install both flavours from packages,
because of overlapping sercmd file.
I added a basic manpage for the tool, a recommendation for each binary
app in many linux distros.
Cheers,
Daniel
--
Daniel-Constantin Mierla - http://www.asipto.comhttp://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat
Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - http://asipto.com/u/katu