### Description
Applying a simple `{s.prefixes}` transformation on a variable with an empty value crashes Kamailio. It is not specific to a particular SIP message being processed.
### Troubleshooting
#### Reproduction
```
request_route {
$var(empty) = "";
$var(result) = $(var(empty){s.prefixes});
drop;
}
```
#### Debugging Data
```
(paste your debugging data here)
```
#### Log Messages
```
kernel: [27707776.714159] kamailio[13060]: segfault at 562232762ff0 ip 00007f82a1e76391 sp 00007ffc3bc7fcd8 error 4 in libc-2.24.so[7f82a1d4d000+195000]
```
#### SIP Traffic
Any SIP traffic will do, as long as this particular scenario is hit, for whatever reason. Could be buggy business logic.
### Possible Solutions
The only thing I could think of is to place the transformation inside an `if` statement which checks for an empty value of the variable the `{s.prefixes]` transformation is being applied to.
### Additional Information
I've tested this with Kamailio 5.1 and 5.4, and both have this issue.
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.4.0 (x86_64/linux)
version: kamailio 5.1.10 (x86_64/linux)
```
* **Operating System**:
```
Kamailio 5.1.10 -> Debian GNU/Linux 9.13 (stretch)
Kamailio 5.4.0 -> Debian GNU/Linux 9.8 (stretch)
```
--
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/2467
Module: kamailio
Branch: master
Commit: bffd78f14921f67735a64caea2fb130393daa2bc
URL: https://github.com/kamailio/kamailio/commit/bffd78f14921f67735a64caea2fb130…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-09-02T14:27:24+02:00
Revert "tls: added define condition on version functions"
This reverts commit 99c6a68dea60ca745dfdfa33085bb6acbcee846a.
---
Modified: src/modules/tls/tls_domain.c
Modified: src/modules/tls/tls_init.c
---
Diff: https://github.com/kamailio/kamailio/commit/bffd78f14921f67735a64caea2fb130…
Patch: https://github.com/kamailio/kamailio/commit/bffd78f14921f67735a64caea2fb130…
---
diff --git a/src/modules/tls/tls_domain.c b/src/modules/tls/tls_domain.c
index 2930bde2be..fc84033e68 100644
--- a/src/modules/tls/tls_domain.c
+++ b/src/modules/tls/tls_domain.c
@@ -63,11 +63,9 @@ static void setup_ecdh(SSL_CTX *ctx)
{
EC_KEY *ecdh;
-#if OPENSSL_VERSION_NUMBER < 0x010100000L
- if (SSLeay() < 0x1000005fL) {
+ if (OpenSSL_version_num() < 0x1000005fL) {
return;
}
-#endif
ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
SSL_CTX_set_options(ctx, SSL_OP_SINGLE_ECDH_USE);
diff --git a/src/modules/tls/tls_init.c b/src/modules/tls/tls_init.c
index f10d0c0344..351ed4187e 100644
--- a/src/modules/tls/tls_init.c
+++ b/src/modules/tls/tls_init.c
@@ -645,7 +645,6 @@ int tls_h_mod_init_f(void)
{
/*struct socket_info* si;*/
long ssl_version;
- const char *ssl_version_txt;
#if OPENSSL_VERSION_NUMBER < 0x010100000L && !defined(LIBRESSL_VERSION_NUMBER)
int lib_kerberos;
int lib_zlib;
@@ -668,15 +667,7 @@ int tls_h_mod_init_f(void)
#if OPENSSL_VERSION_NUMBER < 0x00907000L
LM_WARN("You are using an old version of OpenSSL (< 0.9.7). Upgrade!\n");
#endif
-
-#if OPENSSL_VERSION_NUMBER < 0x010100000L
- ssl_version=SSLeay();
- ssl_version_txt=SSLeay_version(SSLEAY_VERSION);
-#else
ssl_version=OpenSSL_version_num();
- ssl_version_txt=OpenSSL_version(OPENSSL_VERSION);
-#endif
-
/* check if version have the same major minor and fix level
* (e.g. 0.9.8a & 0.9.8c are ok, but 0.9.8 and 0.9.9x are not)
* - values is represented as 0xMMNNFFPPS: major minor fix patch status
@@ -688,7 +679,7 @@ int tls_h_mod_init_f(void)
" compiled \"%s\" (0x%08lx).\n"
" Please make sure a compatible version is used"
" (tls_force_run in kamailio.cfg will override this check)\n",
- ssl_version_txt, ssl_version,
+ OpenSSL_version(OPENSSL_VERSION), ssl_version,
OPENSSL_VERSION_TEXT, (long)OPENSSL_VERSION_NUMBER);
if (cfg_get(tls, tls_cfg, force_run))
LM_WARN("tls_force_run turned on, ignoring "