Module: kamailio
Branch: master
Commit: 2ae296f5d8fa2baa2d451213d668fdd8fabe06d9
URL: https://github.com/kamailio/kamailio/commit/2ae296f5d8fa2baa2d451213d668fdd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-09-23T09:06:51+02:00
posops: handle negative index parameter for find functions
---
Modified: src/modules/posops/doc/posops_admin.xml
Modified: src/modules/posops/posops_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/2ae296f5d8fa2baa2d451213d668fdd…
Patch: https://github.com/kamailio/kamailio/commit/2ae296f5d8fa2baa2d451213d668fdd…
---
diff --git a/src/modules/posops/doc/posops_admin.xml b/src/modules/posops/doc/posops_admin.xml
index 7aa9620343..b0b67b117e 100644
--- a/src/modules/posops/doc/posops_admin.xml
+++ b/src/modules/posops/doc/posops_admin.xml
@@ -246,7 +246,8 @@ $var(pos) = pos_body_end();
val is at index 0, it returns the value specified by modparam idx0.
</para>
<para>
- The idx can be an integer value or a variable holding an integer.
+ The idx can be an integer value or a variable holding an integer. If
+ the value is negative, the position is counted from the end of the buffer.
</para>
<para>
The val can be a static string or variables.
@@ -274,7 +275,8 @@ $var(idx) = pos_find_str("100", "kamailio");
by modparam idx0.
</para>
<para>
- The idx can be an integer value or a variable holding an integer.
+ The idx can be an integer value or a variable holding an integer. If
+ the value is negative, the position is counted from the end of the buffer.
</para>
<para>
The val can be a static string or variables.
diff --git a/src/modules/posops/posops_mod.c b/src/modules/posops/posops_mod.c
index 8c538720ce..6e367c53aa 100644
--- a/src/modules/posops/posops_mod.c
+++ b/src/modules/posops/posops_mod.c
@@ -427,13 +427,15 @@ static int ki_posops_pos_find_str(sip_msg_t *msg, int idx, str *val)
char *p;
str text;
- if(idx<0 || val==NULL || val->s==NULL || val->len<=0) {
+ if(val==NULL || val->s==NULL || val->len<=0) {
return -1;
}
- if(idx > msg->len - val->len) {
+ if(idx<0) {
+ idx += msg->len;
+ }
+ if(idx<0 || idx > msg->len - val->len) {
return -1;
}
-
text.s = msg->buf + idx;
text.len = msg->len - idx;
p = str_search(&text, val);
@@ -476,10 +478,13 @@ static int ki_posops_pos_findi_str(sip_msg_t *msg, int idx, str *val)
char *p;
str text;
- if(idx<0 || val==NULL || val->s==NULL || val->len<=0) {
+ if(val==NULL || val->s==NULL || val->len<=0) {
return -1;
}
- if(idx > msg->len - val->len) {
+ if(idx<0) {
+ idx += msg->len;
+ }
+ if(idx<0 || idx > msg->len - val->len) {
return -1;
}
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for feature requests.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If you submit a feature request (or enhancement) add the description of what you would like to be added.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
how to choose 2 different rr heads when relay a public call to lan? Thanks!
### Expected behavior
#### Actual observed behavior
#### Debugging Data
```
(paste your debugging data here)
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your log messages here)
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a improvement.
-->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
kamailio 5.5.1
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
debian10
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2861
Hello,
Kamailio SIP Server v5.4.7 stable release is out.
This is a maintenance release of the latest stable branch, 5.4, that
includes fixes since the release of v5.4.6. There is no change to
database schema or configuration language structure that you have to do
on previous installations of v5.4.x. Deployments running previous v5.4.x
versions are strongly recommended to be upgraded to v5.4.7.
Note that 5.4 is the second last stable branch, still officially maintained
by Kamailio development team. The latest stable branch is 5.5, with
v5.5.2 being release out of it.
For more details about version 5.4.7 (including links and guidelines to
download the tarball or from GIT repository), visit:
* https://www.kamailio.org/w/2021/09/kamailio-v5-4-7-released/
RPM, Debian/Ubuntu packages will be available soon as well.
Many thanks to all contributing and using Kamailio!
Cheers,
Daniel
--
Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online - June 7-10, 2021 (America Timezone)
* https://www.asipto.com/sw/kamailio-advanced-training-online/