[sr-dev] git:4.4:1765576b: tsilo: check return code for parse_uri()

2017-07-24 Thread Federico Cabiddu
Module: kamailio
Branch: 4.4
Commit: 1765576b013524e73131b9adb4d4ccb78de43658
URL: 
https://github.com/kamailio/kamailio/commit/1765576b013524e73131b9adb4d4ccb78de43658

Author: Daniel-Constantin Mierla 
Committer: Federico Cabiddu 
Date: 2017-07-24T15:19:03+02:00

tsilo: check return code for parse_uri()

(cherry picked from commit a19a06f6c302a7fbac9b137cc1558d47730ead2f)

---

Modified: modules/tsilo/ts_append.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/1765576b013524e73131b9adb4d4ccb78de43658.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1765576b013524e73131b9adb4d4ccb78de43658.patch

---

diff --git a/modules/tsilo/ts_append.c b/modules/tsilo/ts_append.c
index db47fdfad7..b0c605a0ee 100644
--- a/modules/tsilo/ts_append.c
+++ b/modules/tsilo/ts_append.c
@@ -51,9 +51,12 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
 
if (use_domain) {
t_uri = ruri;
-   }
-   else {
-   parse_uri(ruri->s, ruri->len, _uri);
+   } else {
+   if(parse_uri(ruri->s, ruri->len, _uri)<0) {
+   LM_ERR("failed to parse uri %.*s\n", ruri->len, 
ruri->s);
+   unlock_entry_by_ruri(ruri);
+   return -1;
+   }
t_uri = _uri.user;
}
 


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:5.0:3bfc9d49: tsilo: check return code for parse_uri()

2017-07-24 Thread Federico Cabiddu
Module: kamailio
Branch: 5.0
Commit: 3bfc9d4955cf3edd64fe29aa3e88d23609360209
URL: 
https://github.com/kamailio/kamailio/commit/3bfc9d4955cf3edd64fe29aa3e88d23609360209

Author: Daniel-Constantin Mierla 
Committer: Federico Cabiddu 
Date: 2017-07-24T15:18:29+02:00

tsilo: check return code for parse_uri()

(cherry picked from commit a19a06f6c302a7fbac9b137cc1558d47730ead2f)

---

Modified: src/modules/tsilo/ts_append.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/3bfc9d4955cf3edd64fe29aa3e88d23609360209.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3bfc9d4955cf3edd64fe29aa3e88d23609360209.patch

---

diff --git a/src/modules/tsilo/ts_append.c b/src/modules/tsilo/ts_append.c
index 0076634109..e6e27e40cc 100644
--- a/src/modules/tsilo/ts_append.c
+++ b/src/modules/tsilo/ts_append.c
@@ -50,9 +50,12 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
 
if (use_domain) {
t_uri = ruri;
-   }
-   else {
-   parse_uri(ruri->s, ruri->len, _uri);
+   } else {
+   if(parse_uri(ruri->s, ruri->len, _uri)<0) {
+   LM_ERR("failed to parse uri %.*s\n", ruri->len, 
ruri->s);
+   unlock_entry_by_ruri(ruri);
+   return -1;
+   }
t_uri = _uri.user;
}
 


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:34265457: tsilo: coherent locking in ts_append

2017-07-24 Thread Federico Cabiddu
Module: kamailio
Branch: master
Commit: 34265457e7c09b56dec295b753fd8250ef8b0c41
URL: 
https://github.com/kamailio/kamailio/commit/34265457e7c09b56dec295b753fd8250ef8b0c41

Author: Federico Cabiddu 
Committer: Federico Cabiddu 
Date: 2017-07-24T15:16:21+02:00

tsilo: coherent locking in ts_append

---

Modified: src/modules/tsilo/ts_append.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/34265457e7c09b56dec295b753fd8250ef8b0c41.diff
Patch: 
https://github.com/kamailio/kamailio/commit/34265457e7c09b56dec295b753fd8250ef8b0c41.patch

---

diff --git a/src/modules/tsilo/ts_append.c b/src/modules/tsilo/ts_append.c
index e6e27e40cc..7d951865f0 100644
--- a/src/modules/tsilo/ts_append.c
+++ b/src/modules/tsilo/ts_append.c
@@ -45,32 +45,31 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
 
int res;
int appended;
-
-   lock_entry_by_ruri(ruri);
-
+   
if (use_domain) {
t_uri = ruri;
} else {
if(parse_uri(ruri->s, ruri->len, _uri)<0) {
LM_ERR("failed to parse uri %.*s\n", ruri->len, 
ruri->s);
-   unlock_entry_by_ruri(ruri);
return -1;
}
t_uri = _uri.user;
}
 
+   lock_entry_by_ruri(t_uri);
+
res = get_ts_urecord(t_uri, &_r);
 
if (res != 0) {
-   LM_ERR("failed to retrieve record for %.*s\n", ruri->len, 
ruri->s);
-   unlock_entry_by_ruri(ruri);
+   LM_ERR("failed to retrieve record for %.*s\n", t_uri->len, 
t_uri->s);
+   unlock_entry_by_ruri(t_uri);
return -1;
}
 
ptr = _r->transactions;
 
while(ptr) {
-   LM_DBG("transaction %u:%u found for %.*s, going to append 
branches\n",ptr->tindex, ptr->tlabel, ruri->len, ruri->s);
+   LM_DBG("transaction %u:%u found for %.*s, going to append 
branches\n",ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s);
 
appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, 
ruri);
if (appended > 0)
@@ -78,7 +77,7 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
ptr = ptr->next;
}
 
-   unlock_entry_by_ruri(ruri);
+   unlock_entry_by_ruri(t_uri);
 
return 1;
 }


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Daniel-Constantin Mierla
The issue on openssl rt seems to be from 2007:

```
Created: | Thu Feb 22 09:48:25 2007
```

Not sure why it was dealt with in 2016. But I think is not relevant here at all.

-- 
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/1189#issuecomment-317400650___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Daniel-Constantin Mierla
So there seems to be some fixes in branch 1.1.0 after release of 1.1.0f, your 
code is no longer matching their git branch.

Their new patch might be related, so maybe you can recompile the latest libssl 
from their 1.1.0 stable branch.

Otherwise, although not really familiar with libssl internals, it doesn't look 
to be anything related to upper layer application, but only some internal/local 
stuff they try to clean on exit. It is not even on cleaning the tls 
context/connections -- that callback seems to be executed because is registered 
with `atexit()`.

-- 
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/1189#issuecomment-317400015___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Victor Seva
This is what I have
```
static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
{
struct thread_local_inits_st *local =
CRYPTO_THREAD_get_local();

if (local == NULL && alloc) {
local = OPENSSL_zalloc(sizeof *local);
CRYPTO_THREAD_set_local(, local);
}
if (!alloc) {
CRYPTO_THREAD_set_local(, NULL);
}

return local;
}
```

-- 
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/1189#issuecomment-317398482___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Daniel-Constantin Mierla
The link from previous comment goes to a page asking for authentication.

The crash happens inside exit() function, due to a callback registered by 
libssl.

Can you check if the version of the libssl you run has the next patch from 
about 1 month ago:

  * 
https://github.com/openssl/openssl/commit/4b4bc00a00456e6d5cc8b2a26489ae905c049f41#diff-a6179475cbd0e12e843d14372560ae41

Looks a bit related, and now the branch 1.1.0 on libssl has just a check for a 
null pointer:

  * 
https://github.com/openssl/openssl/blob/OpenSSL_1_1_0-stable/crypto/init.c#L332

-- 
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/1189#issuecomment-317397594___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Victor Seva
downloaded openssl source
```
#0  ossl_init_thread_stop (locals=0x7faaf4442d58) at ../crypto/init.c:332
332 if (locals->async) {
(gdb) p locals
$1 = (struct thread_local_inits_st *) 0x7faaf4442d58
(gdb) p *locals
Cannot access memory at address 0x7faaf4442d58
```

-- 
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/1189#issuecomment-317397086___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Victor Seva
FTR https://rt.openssl.org/Ticket/Display.html?id=1491 has been closed with

> This is reported against 0.9.8;  please open a new ticket if still a problem 
> with current releases.

-- 
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/1189#issuecomment-317395465___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Victor Seva
backporting [0] and [1] didn't help
[0] 
https://github.com/kamailio/kamailio/commit/e7c03ce6ce61119fbf5cb9f41b7abcd4c7138d58
[1] 
https://github.com/kamailio/kamailio/commit/76efc9b7a1489007f9ff431e730ce4e86b446a6c
 

-- 
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/1189#issuecomment-317395129___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] [kamailio/kamailio] cores on stop if TLS is enabled using libssl1.1 ( Debian stretch ) (#1189)

2017-07-24 Thread Victor Seva
### Description

We are having cores when stopping the lb service if TLS is enabled.

### Troubleshooting

 Debugging Data

```
Core was generated by `/usr/sbin/kamailio -f /etc/kamailio/lb/kamailio.cfg -P 
/var/run/kamailio/kamail'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  ossl_init_thread_stop (locals=0x7faaf4442d58) at ../crypto/init.c:332
332 ../crypto/init.c: No such file or directory.
(gdb) bt full
#0  ossl_init_thread_stop (locals=0x7faaf4442d58) at ../crypto/init.c:332
No locals.
#1  0x7faaf8d15234 in OPENSSL_cleanup () at ../crypto/init.c:400
currhandler = 
lasthandler = 
#2  0x7fab014bb910 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#3  0x7fab014bb96a in exit () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#4  0x556782094615 in handle_sigs () at main.c:698
chld = 
chld_status = 0
memlog = 
__func__ = "handle_sigs"
#5  0x55678209aa05 in main_loop () at main.c:1747

```

 Log Messages
```
lb[8618]: WARNING: tls [tls_init.c:704]: init_tls_h(): tls: openssl bug #1491 
(crash/mem leaks on low memory) workaround enabled (on low memory tls 
operations will fail preemptively) with free memory thresholds 7340032 and 
3670016 bytes
```

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
This is NGCP version based on 4.4.6

kamailio -v
version: kamailio 4.4.6 (x86_64/linux) becbde
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, 
USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, 
TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, 
USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, 
MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: becbde 
compiled with gcc 6.3.0
```

* **Operating System**:

```
Debian stretch
Linux spce 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 
GNU/Linux
libssl1.1 version 1.1.0f-3
```


-- 
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/1189___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:0cf4ad7b: app_perl: free on error cases for modf execution

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 0cf4ad7b4e839856eef4dc2cd76adacd1627ce7c
URL: 
https://github.com/kamailio/kamailio/commit/0cf4ad7b4e839856eef4dc2cd76adacd1627ce7c

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T13:24:49+02:00

app_perl: free on error cases for modf execution

---

Modified: src/modules/app_perl/kamailioxs.xs

---

Diff:  
https://github.com/kamailio/kamailio/commit/0cf4ad7b4e839856eef4dc2cd76adacd1627ce7c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/0cf4ad7b4e839856eef4dc2cd76adacd1627ce7c.patch

---

diff --git a/src/modules/app_perl/kamailioxs.xs 
b/src/modules/app_perl/kamailioxs.xs
index 8d2604c1a5..385fa1a115 100644
--- a/src/modules/app_perl/kamailioxs.xs
+++ b/src/modules/app_perl/kamailioxs.xs
@@ -289,6 +289,7 @@ int moduleFunc(struct sip_msg *m, char *func,
LM_ERR("Module function '%s' is unsafe. Call is 
refused.\n", func);
if (argv[0]) pkg_free(argv[0]);
if (argv[1]) pkg_free(argv[1]);
+   pkg_free(act);
*retval = -1;
return -1;
}
@@ -297,6 +298,9 @@ int moduleFunc(struct sip_msg *m, char *func,
*retval = exp_func_struct->fixup(&(act->val[3].u.data), 
2);
if (*retval < 0) {
LM_ERR("Error in fixup (2)\n");
+   if (argv[0]) pkg_free(argv[0]);
+   if (argv[1]) pkg_free(argv[1]);
+   pkg_free(act);
return -1;
}
act->val[3].type = MODFIXUP_ST;
@@ -305,6 +309,9 @@ int moduleFunc(struct sip_msg *m, char *func,
*retval = exp_func_struct->fixup(&(act->val[2].u.data), 
1);
if (*retval < 0) {
LM_ERR("Error in fixup (1)\n");
+   if (argv[0]) pkg_free(argv[0]);
+   if (argv[1]) pkg_free(argv[1]);
+   pkg_free(act);
return -1;
}
act->val[2].type = MODFIXUP_ST;
@@ -313,6 +320,9 @@ int moduleFunc(struct sip_msg *m, char *func,
*retval = exp_func_struct->fixup(0, 0);
if (*retval < 0) {
LM_ERR("Error in fixup (0)\n");
+   if (argv[0]) pkg_free(argv[0]);
+   if (argv[1]) pkg_free(argv[1]);
+   pkg_free(act);
return -1;
}
}
@@ -337,7 +347,7 @@ int moduleFunc(struct sip_msg *m, char *func,
if (argv[1]) pkg_free(argv[1]);
 
pkg_free(act);
-   
+
return 1;
 }
 
@@ -699,7 +709,9 @@ getFullHeader(self)
LM_ERR("getFullHeader: Invalid message type.\n");
ST(0)  = _sv_undef;
} else {
-   parse_headers(msg, ~0, 0);
+   if(parse_headers(msg, ~0, 0)<0) {
+   LM_ERR("failed to parse headers\n");
+   }
if (getType(msg) == SIP_REQUEST) {
firsttoken = 
(msg->first_line).u.request.method.s;
} else { /* SIP_REPLY */
@@ -713,7 +725,7 @@ getFullHeader(self)
-((long)(firsttoken));
 
if (headerlen > 0) {
-   ST(0) = 
+   ST(0) =
sv_2mortal(newSVpv(firsttoken, headerlen));
} else {
ST(0) = _sv_undef;
@@ -739,7 +751,9 @@ getBody(self)
LM_ERR("Invalid message reference\n");
ST(0) = _sv_undef;
} else {
-   parse_headers(msg, ~0, 0);
+   if(parse_headers(msg, ~0, 0)<0) {
+   LM_ERR("failed to parse headers\n");
+   }
ST(0) = sv_2mortal(newSVpv(get_body(msg), 0));
}
 
@@ -792,7 +806,9 @@ getHeader(self, name)
if (!msg) {
LM_ERR("Invalid message reference\n");
} else {
-   parse_headers(msg, ~0, 0);
+   if(parse_headers(msg, ~0, 0)<0) {
+   LM_ERR("failed to parse headers\n");
+   }
for (hf = msg->headers; hf; hf = hf->next) {
if (namelen == hf->name.len) {
if (strncmp(name, hf->name.s, namelen) == 0) {
@@ -825,11 +841,13 @@ getHeaderNames(self)
 struct hdr_field *hf = NULL;
 int found = 0;
   PPCODE:
-   
+

Re: [sr-dev] [kamailio/kamailio] redis support into usrloc (#1137)

2017-07-24 Thread Surendra Tiwari
this will be available soon.some memory fixes are going on.right now its usable 
with usrloc module.but after first version of this module we will update this 
on frequently.

-- 
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/1137#issuecomment-317393382___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:96582d77: xcap_client: safety check for namespace variable

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 96582d77583719d7bb9c5e5437198800ae9e7a12
URL: 
https://github.com/kamailio/kamailio/commit/96582d77583719d7bb9c5e5437198800ae9e7a12

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T12:22:00+02:00

xcap_client: safety check for namespace variable

---

Modified: src/modules/xcap_client/xcap_functions.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/96582d77583719d7bb9c5e5437198800ae9e7a12.diff
Patch: 
https://github.com/kamailio/kamailio/commit/96582d77583719d7bb9c5e5437198800ae9e7a12.patch

---

diff --git a/src/modules/xcap_client/xcap_functions.c 
b/src/modules/xcap_client/xcap_functions.c
index 6b875b17d0..cee161b7d0 100644
--- a/src/modules/xcap_client/xcap_functions.c
+++ b/src/modules/xcap_client/xcap_functions.c
@@ -223,7 +223,7 @@ xcap_node_sel_t* xcapNodeSelAddStep(xcap_node_sel_t* 
curr_sel, str* name,
}
 
curr_sel->size+= 1+ new_step.len;
-   if(namespace->len)
+   if(namespace && namespace->len)
{
curr_sel->size+= namespace->len+ 3;
}


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:e6e04f4c: xcap_client: removed unused api function get_elem()

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: e6e04f4c96e5fdd7a3a90f265fd6cb7470f1135b
URL: 
https://github.com/kamailio/kamailio/commit/e6e04f4c96e5fdd7a3a90f265fd6cb7470f1135b

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T12:15:55+02:00

xcap_client: removed unused api function get_elem()

---

Modified: src/modules/xcap_client/xcap_functions.c
Modified: src/modules/xcap_client/xcap_functions.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/e6e04f4c96e5fdd7a3a90f265fd6cb7470f1135b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/e6e04f4c96e5fdd7a3a90f265fd6cb7470f1135b.patch

---

diff --git a/src/modules/xcap_client/xcap_functions.c 
b/src/modules/xcap_client/xcap_functions.c
index 1b2e6b457f..6b875b17d0 100644
--- a/src/modules/xcap_client/xcap_functions.c
+++ b/src/modules/xcap_client/xcap_functions.c
@@ -50,7 +50,6 @@ int bind_xcap(xcap_api_t* api)
LM_ERR("Invalid parameter value\n");
return -1;
}
-   api->get_elem= xcapGetElem;
api->int_node_sel= xcapInitNodeSel;
api->add_step= xcapNodeSelAddStep;
api->add_terminal= xcapNodeSelAddTerminal;
@@ -455,39 +454,6 @@ char* get_xcap_path(xcap_get_req_t req)
return NULL;
 }
 
-/* xcap_root must be a NULL terminated string */
-
-char* xcapGetElem(xcap_get_req_t req, char** etag)
-{
-   char* path= NULL;
-   char* stream= NULL;
-
-   path= get_xcap_path(req);
-   if(path== NULL)
-   {
-   LM_ERR("while constructing xcap path\n");
-   return NULL;
-   }
-
-   stream= send_http_get(path, req.port, req.etag, req.match_type, etag);
-   if(stream== NULL)
-   {
-   LM_DBG("the serched element was not found\n");
-   }
-
-   if(etag== NULL)
-   {
-   LM_ERR("no etag found\n");
-   pkg_free(stream);
-   stream= NULL;
-   }
-
-   if(path)
-   pkg_free(path);
-
-   return stream;
-}
-
 size_t get_xcap_etag( void *ptr, size_t size, size_t nmemb, void *stream)
 {
int len= 0;
diff --git a/src/modules/xcap_client/xcap_functions.h 
b/src/modules/xcap_client/xcap_functions.h
index 8750aeae53..44ae635972 100644
--- a/src/modules/xcap_client/xcap_functions.h
+++ b/src/modules/xcap_client/xcap_functions.h
@@ -103,11 +103,6 @@ xcap_node_sel_t* xcapNodeSelAddTerminal(xcap_node_sel_t* 
curr_sel,
 typedef xcap_node_sel_t* (*xcap_nodeSel_add_terminal_t)(xcap_node_sel_t* 
curr_sel,
char* attr_sel, char* namespace_sel, char* extra_sel );
 
-/* generical function to get an element from an xcap server */
-char* xcapGetElem(xcap_get_req_t req, char** etag);
-
-typedef char* (*xcap_get_elem_t)(xcap_get_req_t req, char** etag);
-
 void xcapFreeNodeSel(xcap_node_sel_t* node);
 
 typedef void (*xcap_nodeSel_free_t)(xcap_node_sel_t* node);
@@ -118,7 +113,6 @@ char* xcapGetNewDoc(xcap_get_req_t req, str user, str 
domain);
 typedef char* (*xcapGetNewDoc_t)(xcap_get_req_t req, str user, str domain);
 
 typedef struct xcap_api {
-   xcap_get_elem_t get_elem;
xcap_nodeSel_init_t int_node_sel;
xcap_nodeSel_add_step_t add_step;
xcap_nodeSel_add_terminal_t add_terminal;


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:8147009b: xcap_client: handle return code for strchr()

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 8147009b34639304fb75d4f6c39269c49ee385ca
URL: 
https://github.com/kamailio/kamailio/commit/8147009b34639304fb75d4f6c39269c49ee385ca

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T12:15:09+02:00

xcap_client: handle return code for strchr()

---

Modified: src/modules/xcap_client/xcap_client.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/8147009b34639304fb75d4f6c39269c49ee385ca.diff
Patch: 
https://github.com/kamailio/kamailio/commit/8147009b34639304fb75d4f6c39269c49ee385ca.patch

---

diff --git a/src/modules/xcap_client/xcap_client.c 
b/src/modules/xcap_client/xcap_client.c
index e96511651d..0b8a707d8d 100644
--- a/src/modules/xcap_client/xcap_client.c
+++ b/src/modules/xcap_client/xcap_client.c
@@ -310,24 +310,33 @@ int parse_doc_url(str doc_url, char** serv_addr, 
xcap_doc_sel_t* doc_sel)
char* sl, *str_type;
 
sl= strchr(doc_url.s, '/');
+   if(sl==NULL) {
+   return -1;
+   }
*sl= '\0';
*serv_addr= doc_url.s;
 
sl++;
doc_sel->auid.s= sl;
sl= strchr(sl, '/');
+   if(sl==NULL) {
+   return -1;
+   }
doc_sel->auid.len= sl- doc_sel->auid.s;
 
sl++;
str_type= sl;
sl= strchr(sl, '/');
+   if(sl==NULL) {
+   return -1;
+   }
*sl= '\0';
 
-   if(strcasecmp(str_type, "users")== 0)
+   if(strcasecmp(str_type, "users")== 0) {
doc_sel->type= USERS_TYPE;
-   else
-   if(strcasecmp(str_type, "group")== 0)
+   } else if(strcasecmp(str_type, "group")== 0) {
doc_sel->type= GLOBAL_TYPE;
+   }
 
sl++;
 


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:37129325: presence_xml: fixed misleading error message

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 371293257d000c004f78068f15a4184df3dbd57b
URL: 
https://github.com/kamailio/kamailio/commit/371293257d000c004f78068f15a4184df3dbd57b

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T12:14:18+02:00

presence_xml: fixed misleading error message

---

Modified: src/modules/presence_xml/presence_xml.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/371293257d000c004f78068f15a4184df3dbd57b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/371293257d000c004f78068f15a4184df3dbd57b.patch

---

diff --git a/src/modules/presence_xml/presence_xml.c 
b/src/modules/presence_xml/presence_xml.c
index da0e056e3e..0f221852d7 100644
--- a/src/modules/presence_xml/presence_xml.c
+++ b/src/modules/presence_xml/presence_xml.c
@@ -242,7 +242,7 @@ static int mod_init(void)
xcap_GetNewDoc= xcap_api.getNewDoc;
if(xcap_GetNewDoc== NULL)
{
-   LM_ERR("can't import get_elem from xcap_client 
module\n");
+   LM_ERR("can't import getNewDoc from xcap_client 
module\n");
return -1;
}
 
@@ -559,4 +559,4 @@ int mod_register(char *path, int *dlflags, void *p1, void 
*p2)
 {
sr_kemi_modules_add(sr_kemi_presence_xml_exports);
return 0;
-}
\ No newline at end of file
+}


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:4ba40243: stun: link attribute when calling stun_parse_body() with an existing list

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 4ba402434449ec9cb426d5200b12c5cec4d07ab4
URL: 
https://github.com/kamailio/kamailio/commit/4ba402434449ec9cb426d5200b12c5cec4d07ab4

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T11:56:57+02:00

stun: link attribute when calling stun_parse_body() with an existing list

---

Modified: src/modules/stun/kam_stun.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/4ba402434449ec9cb426d5200b12c5cec4d07ab4.diff
Patch: 
https://github.com/kamailio/kamailio/commit/4ba402434449ec9cb426d5200b12c5cec4d07ab4.patch

---

diff --git a/src/modules/stun/kam_stun.c b/src/modules/stun/kam_stun.c
index 8257fbab4c..350317b0e7 100644
--- a/src/modules/stun/kam_stun.c
+++ b/src/modules/stun/kam_stun.c
@@ -336,8 +336,10 @@ static int stun_parse_body(
}
if (*unknown == NULL) {
*unknown = body = tmp_unknown;
-   }
-   else { 
+   } else {
+   if(body==NULL) {
+   body = *unknown;
+   }
body->next = tmp_unknown;
body = body->next;
}


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] redis support into usrloc (#1137)

2017-07-24 Thread ng-voice GmbH
Questions:
- is there a timeline available? When will this be available for testing? Can I 
get a preview?
- will this work like the generic database modules? I'd love to test/use this 
with the ims_* modules

Thanks,
Carsten

-- 
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/1137#issuecomment-317378877___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:f75eba63: statsd: simplified error handling inside statsd_connect()

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: f75eba63a1f0176adc8cd38846a0d1943471e10c
URL: 
https://github.com/kamailio/kamailio/commit/f75eba63a1f0176adc8cd38846a0d1943471e10c

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T11:44:21+02:00

statsd: simplified error handling inside statsd_connect()

---

Modified: src/modules/statsd/lib_statsd.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/f75eba63a1f0176adc8cd38846a0d1943471e10c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/f75eba63a1f0176adc8cd38846a0d1943471e10c.patch

---

diff --git a/src/modules/statsd/lib_statsd.c b/src/modules/statsd/lib_statsd.c
index bbda181d6a..79d99fcfbd 100644
--- a/src/modules/statsd/lib_statsd.c
+++ b/src/modules/statsd/lib_statsd.c
@@ -29,25 +29,24 @@ bool statsd_connect(void){
 rc = getaddrinfo(
 statsd_connection.ip, statsd_connection.port,
 NULL, );
-if (rc != 0)
+if (rc != 0 || serverAddr == NULL)
 {
-LM_ERR(
-"Statsd: could not initiate server information (%s)\n",
+LM_ERR("Statsd: could not initiate server information (%s)\n",
 gai_strerror(rc));
-   if(serverAddr) freeaddrinfo(serverAddr);
+if(serverAddr) freeaddrinfo(serverAddr);
 return false;
 }
 
 statsd_connection.sock = socket(serverAddr->ai_family, SOCK_DGRAM, 
IPPROTO_UDP);
 if (statsd_connection.sock < 0 ){
 LM_ERR("Statsd: could not create a socket for statsd connection\n");
-   if(serverAddr) freeaddrinfo(serverAddr);
+freeaddrinfo(serverAddr);
 return false;
 }
 
-rc = connect(
-statsd_connection.sock, serverAddr->ai_addr, serverAddr->ai_addrlen);
-   freeaddrinfo(serverAddr);
+rc = connect(statsd_connection.sock, serverAddr->ai_addr,
+serverAddr->ai_addrlen);
+freeaddrinfo(serverAddr);
 if (rc < 0){
 LM_ERR("Statsd: could not initiate a connect to statsd\n");
 return false;


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:711a5600: statistics: free vars in case of error in fixup function

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 711a5600330793b2ca787ce451f2ad48620dd639
URL: 
https://github.com/kamailio/kamailio/commit/711a5600330793b2ca787ce451f2ad48620dd639

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T11:38:51+02:00

statistics: free vars in case of error in fixup function

---

Modified: src/modules/statistics/statistics.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/711a5600330793b2ca787ce451f2ad48620dd639.diff
Patch: 
https://github.com/kamailio/kamailio/commit/711a5600330793b2ca787ce451f2ad48620dd639.patch

---

diff --git a/src/modules/statistics/statistics.c 
b/src/modules/statistics/statistics.c
index 499b4198ba..c5ace8c185 100644
--- a/src/modules/statistics/statistics.c
+++ b/src/modules/statistics/statistics.c
@@ -135,6 +135,7 @@ static int fixup_stat(void** param, int param_no)
if (s.s[0]=='$') {
if (fixup_pvar_null(param, 1)!=0) {
LM_ERR("invalid pv %s as parameter\n",s.s);
+   pkg_free(sopv);
return E_CFG;
}
sopv->pv = (pv_spec_t*)(*param);
@@ -143,10 +144,10 @@ static int fixup_stat(void** param, int param_no)
sopv->stat = get_stat(  );
if (sopv->stat==0) {
LM_ERR("variable <%s> not defined\n", s.s);
+   pkg_free(sopv);
return E_CFG;
}
}
-   pkg_free(s.s);
*param=(void*)sopv;
return 0;
} else if (param_no==2) {
@@ -160,6 +161,7 @@ static int fixup_stat(void** param, int param_no)
if (s.s[0] == '$') {
if (fixup_pvar_pvar(param, 2) != 0) {
LM_ERR("invalid pv %s as parameter\n",s.s);
+   pkg_free(lopv);
return E_CFG;
}
lopv->pv = (pv_spec_t*) (*param);
@@ -179,13 +181,14 @@ static int fixup_stat(void** param, int param_no)
if (err==0){
if (n==0 && (s.s[0]!='$')) {//we can't check the 
value of the pvar so have to ignore this check if it is a pvar
LM_ERR("update with 0 has no sense\n");
+   pkg_free(lopv);
return E_CFG;
}
-   pkg_free(s.s);
*param=(void*)lopv;
return 0;
}else{
LM_ERR("bad update number <%s>\n",(char*)(*param));
+   pkg_free(lopv);
return E_CFG;
}
}


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:6997738a: sst: add 0 after memcpy

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 6997738a7098ef56becfd40cb6e7c7864d1975f0
URL: 
https://github.com/kamailio/kamailio/commit/6997738a7098ef56becfd40cb6e7c7864d1975f0

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T08:26:38+02:00

sst: add 0 after memcpy

---

Modified: src/modules/sst/sst_handlers.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/6997738a7098ef56becfd40cb6e7c7864d1975f0.diff
Patch: 
https://github.com/kamailio/kamailio/commit/6997738a7098ef56becfd40cb6e7c7864d1975f0.patch

---

diff --git a/src/modules/sst/sst_handlers.c b/src/modules/sst/sst_handlers.c
index ba1d4928b0..be55eb8883 100644
--- a/src/modules/sst/sst_handlers.c
+++ b/src/modules/sst/sst_handlers.c
@@ -791,11 +791,12 @@ static int append_header(struct sip_msg *msg, const char 
*header)
return(1);
}
len = strlen(header);
-   if ((s = (char *)pkg_malloc(len)) == 0) {
+   if ((s = (char *)pkg_malloc(len+1)) == 0) {
LM_ERR("No more pkg memory. (size requested = %d)\n", len);
return(1);
}
memcpy(s, header, len);
+   s[len] = '\0';
if (insert_new_lump_before(anchor, s, len, 0) == 0) {
LM_ERR("failed to insert lump\n");
pkg_free(s);


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:823bad5f: uid_uri_db: safer check for accessing to header

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 823bad5f3aad5c77ff9986ecf4be2517df043788
URL: 
https://github.com/kamailio/kamailio/commit/823bad5f3aad5c77ff9986ecf4be2517df043788

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-24T08:22:24+02:00

uid_uri_db: safer check for accessing to header

---

Modified: src/modules/uid_uri_db/uid_uri_db_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/823bad5f3aad5c77ff9986ecf4be2517df043788.diff
Patch: 
https://github.com/kamailio/kamailio/commit/823bad5f3aad5c77ff9986ecf4be2517df043788.patch

---

diff --git a/src/modules/uid_uri_db/uid_uri_db_mod.c 
b/src/modules/uid_uri_db/uid_uri_db_mod.c
index 4e5771f493..dba6454b81 100644
--- a/src/modules/uid_uri_db/uid_uri_db_mod.c
+++ b/src/modules/uid_uri_db/uid_uri_db_mod.c
@@ -238,14 +238,14 @@ static int lookup_uid(struct sip_msg* msg, long id, int 
store)
} else if (id == USE_TO) {
get_to_did(, msg);
if (!msg->to) {
-   if (parse_headers( msg, HDR_TO_F, 0 )==-1) {
+   if (parse_headers(msg, HDR_TO_F, 0)==-1 || !msg->to) {
ERR("unable to parse To header\n");
return -1;
}
}
to = get_to(msg);
if (!to) {
-   LOG(L_ERR, "uri_db:lookup_uid: Unable to get To 
username\n");
+   LOG(L_ERR, "uri_db:lookup_uid: Unable to get To 
body\n");
return -1;
}
if (parse_uri(to->uri.s, to->uri.len, ) < 0) {


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:dd0c6fb5: msilo: reorganized tests to free db_res and build of extra headers

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: dd0c6fb586a61cb7e2eed1093ccf8f5158761ae3
URL: 
https://github.com/kamailio/kamailio/commit/dd0c6fb586a61cb7e2eed1093ccf8f5158761ae3

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-23T09:42:21+02:00

msilo: reorganized tests to free db_res and build of extra headers

---

Modified: src/modules/msilo/msfuncs.c
Modified: src/modules/msilo/msilo.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/dd0c6fb586a61cb7e2eed1093ccf8f5158761ae3.diff
Patch: 
https://github.com/kamailio/kamailio/commit/dd0c6fb586a61cb7e2eed1093ccf8f5158761ae3.patch

---

diff --git a/src/modules/msilo/msfuncs.c b/src/modules/msilo/msfuncs.c
index 43bc82ce60..5262a81159 100644
--- a/src/modules/msilo/msfuncs.c
+++ b/src/modules/msilo/msfuncs.c
@@ -211,30 +211,30 @@ int m_build_headers(str *buf, str ctype, str contact, 
time_t date, str extra)
if(date > 0)
{
lenDate = timetToSipDateStr(date,strDate,48);
-   strncpy(p, strDate, lenDate);
+   memcpy(p, strDate, lenDate);
p += lenDate;
}
if(ctype.len > 0)
{
-   strncpy(p, "Content-Type: ", 14);
+   memcpy(p, "Content-Type: ", 14);
p += 14;
-   strncpy(p, ctype.s, ctype.len);
+   memcpy(p, ctype.s, ctype.len);
p += ctype.len;
-   strncpy(p, CRLF, CRLF_LEN);
+   memcpy(p, CRLF, CRLF_LEN);
p += CRLF_LEN;

}
if(contact.len > 0 && ms_add_contact)
{
-   strncpy(p, CONTACT_PREFIX, CONTACT_PREFIX_LEN);
+   memcpy(p, CONTACT_PREFIX, CONTACT_PREFIX_LEN);
p += CONTACT_PREFIX_LEN;
-   strncpy(p, contact.s, contact.len);
+   memcpy(p, contact.s, contact.len);
p += contact.len;
-   strncpy(p, CONTACT_SUFFIX, CONTACT_SUFFIX_LEN);
+   memcpy(p, CONTACT_SUFFIX, CONTACT_SUFFIX_LEN);
p += CONTACT_SUFFIX_LEN;
}
if (extra.len > 0) {
-   strncpy(p, extra.s, extra.len);
+   memcpy(p, extra.s, extra.len);
p += extra.len;
}
buf->len = p - buf->s;  
@@ -263,18 +263,18 @@ int m_build_body(str *body, time_t date, str msg, time_t 
sdate)
{
if(sdate!=0)
{
-   strncpy(p, "[Reminder message - ", 20);
+   memcpy(p, "[Reminder message - ", 20);
p += 20;

-   strncpy(p, ctime(), 24);
+   memcpy(p, ctime(), 24);
p += 24;
 
*p++ = ']';
} else {
-   strncpy(p, "[Offline message - ", 19);
+   memcpy(p, "[Offline message - ", 19);
p += 19;

-   strncpy(p, ctime(), 24);
+   memcpy(p, ctime(), 24);
p += 24;
 
*p++ = ']';
diff --git a/src/modules/msilo/msilo.c b/src/modules/msilo/msilo.c
index d231ae7e6e..f62557ce2a 100644
--- a/src/modules/msilo/msilo.c
+++ b/src/modules/msilo/msilo.c
@@ -1039,8 +1039,11 @@ static int m_dump(struct sip_msg* msg, str* owner_s)
}
 
if (msilo_dbf.query(db_con,db_keys,db_ops,db_vals,db_cols,db_no_keys,
-   db_no_cols, ob_key, _res) < 0) {
+   db_no_cols, ob_key, _res) < 0 || db_res==NULL) {
LM_ERR("failed to query database\n");
+   if (db_res!=NULL && msilo_dbf.free_result(db_con, db_res) < 0) {
+   LM_ERR("failed to free the query result\n");
+   }
goto error;
}
 
@@ -1071,13 +1074,13 @@ static int m_dump(struct sip_msg* msg, str* owner_s)
(time_t)RES_ROWS(db_res)[i].values[5/*inc 
time*/].val.int_val;

if (ms_extra_hdrs != NULL) {
-   if (fixup_get_svalue(msg, (gparam_p)*ms_extra_hdrs_sp,
-_hdrs_str) != 0) {
-   if (msilo_dbf.free_result(db_con, db_res) < 0)
-   LM_ERR("failed to free the query result\n");
-   LM_ERR("unable to get extra_hdrs value\n");
-   goto error;
-   }
+   if(fixup_get_svalue(msg, (gparam_p)*ms_extra_hdrs_sp,
+   _hdrs_str) != 0) {
+   if(msilo_dbf.free_result(db_con, db_res) < 0)
+   LM_ERR("failed to free the query 
result\n");
+   LM_ERR("unable to get extra_hdrs value\n");
+   goto error;
+   }
} 

[sr-dev] git:master:021e49d6: tm: refactored error handling for eval_uac_routing()

2017-07-24 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 021e49d6293cc156cd85791dfc9d59307e62fba0
URL: 
https://github.com/kamailio/kamailio/commit/021e49d6293cc156cd85791dfc9d59307e62fba0

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2017-07-23T10:08:47+02:00

tm: refactored error handling for eval_uac_routing()

---

Modified: src/modules/tm/t_msgbuilder.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/021e49d6293cc156cd85791dfc9d59307e62fba0.diff
Patch: 
https://github.com/kamailio/kamailio/commit/021e49d6293cc156cd85791dfc9d59307e62fba0.patch

---

diff --git a/src/modules/tm/t_msgbuilder.c b/src/modules/tm/t_msgbuilder.c
index 3bd76b32fe..c4ab254076 100644
--- a/src/modules/tm/t_msgbuilder.c
+++ b/src/modules/tm/t_msgbuilder.c
@@ -912,7 +912,6 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct 
retr_buf *inv_rb,
int is_req;
struct sip_uri puri;
static size_t chklen;
-   int ret = -1;
 
/* parse the retr. buffer */
memset(_inv, 0, sizeof(struct sip_msg));
@@ -931,14 +930,14 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct 
retr_buf *inv_rb,
/* the bug is at message assembly */
LM_BUG("failed to parse INVITE retr. buffer and/or extract 'To' 
HF:"
"\n%.*s\n", (int)orig_inv.len, orig_inv.buf);
-   goto end;
+   goto error;
}
if (((struct to_body *)orig_inv.to->parsed)->tag_value.len) {
LM_DBG("building ACK for in-dialog INVITE (using RS in orig. 
INV.)\n");
if (parse_headers(_inv, HDR_EOH_F, 0) < 0) {
LM_BUG("failed to parse INVITE retr. buffer to EOH:"
"\n%.*s\n", (int)orig_inv.len, 
orig_inv.buf);
-   goto end;
+   goto error;
}
sipmsg = _inv;
is_req = 1;
@@ -951,7 +950,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct 
retr_buf *inv_rb,
/* extract the route set */
if (get_uac_rs(sipmsg, is_req, ) < 0) {
LM_ERR("failed to extract route set.\n");
-   goto end;
+   goto error;
}
 
if (! rtset) { /* No routes */
@@ -961,7 +960,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct 
retr_buf *inv_rb,
if (parse_uri(rtset->ptr->nameaddr.uri.s, 
rtset->ptr->nameaddr.uri.len,
) < 0) {
LM_ERR("failed to parse first route in set.\n");
-   goto end;
+   goto error;
}
 
if (puri.lr.s) { /* Next hop is loose router */
@@ -993,7 +992,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct 
retr_buf *inv_rb,
} else {
LM_ERR("failed to establish what kind of router 
the next "
"hop is.\n");
-   goto end;
+   goto error;
}
break;
case F_RB_NH_LOOSE:
@@ -1028,8 +1027,7 @@ static int eval_uac_routing(sip_msg_t *rpl, const struct 
retr_buf *inv_rb,
} else {
prev_t->next = NULL;
}
-   ret = -1;
-   goto end;
+   goto error;
}
/* this way, .free_rr is also set to 0 (!!!) */
memset(t, 0, chklen);
@@ -1054,19 +1052,21 @@ static int eval_uac_routing(sip_msg_t *rpl, const 
struct retr_buf *inv_rb,
 #ifdef EXTRA_DEBUG
abort();
 #else
-   goto end;
+   goto error;
 #endif
}
}
 
*list = rtset;
+   free_sip_msg(_inv);
/* all went well */
-   ret = 0;
-end:
+   return 0;
+
+error:
free_sip_msg(_inv);
-   if (ret < 0)
+   if (rtset)
free_rte_list(rtset);
-   return ret;
+   return -1;
 }
 
 /*


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev