mirror of https://github.com/sipwise/kamailio.git
* remove patches for redis (NULL key) * remove patches for rtpenigne (directional flag) * remove patches for permissions (reload in the middle) * adaptation of kamctl TMPDIR config * adaptation of lcr rate module Change-Id: I64ab5d90b7d5e206d1367d70445b8942bc15b487master
parent
89359fc5f7
commit
2f00333e09
@ -1,140 +0,0 @@
|
|||||||
From: Sipwise Development Team <support@sipwise.com>
|
|
||||||
Date: Tue, 13 Jan 2026 09:50:54 +0100
|
|
||||||
Subject: db_redis_protect_length_overflow
|
|
||||||
|
|
||||||
---
|
|
||||||
src/modules/db_redis/db_redis_mod.c | 2 ++
|
|
||||||
src/modules/db_redis/redis_dbase.c | 7 +++----
|
|
||||||
src/modules/db_redis/redis_table.c | 33 ++++++++++++++++++++++++++++-----
|
|
||||||
src/modules/db_redis/redis_table.h | 4 ++--
|
|
||||||
4 files changed, 35 insertions(+), 11 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/db_redis/db_redis_mod.c b/src/modules/db_redis/db_redis_mod.c
|
|
||||||
index 11c7b8c..fafafbb 100644
|
|
||||||
--- a/src/modules/db_redis/db_redis_mod.c
|
|
||||||
+++ b/src/modules/db_redis/db_redis_mod.c
|
|
||||||
@@ -42,6 +42,7 @@ MODULE_VERSION
|
|
||||||
str redis_keys = str_init("");
|
|
||||||
str redis_schema_path = str_init(SHARE_DIR "db_redis/kamailio");
|
|
||||||
int db_redis_verbosity = 1;
|
|
||||||
+unsigned int db_redis_max_key_len = 0;
|
|
||||||
|
|
||||||
static int db_redis_bind_api(db_func_t *dbb);
|
|
||||||
static int mod_init(void);
|
|
||||||
@@ -60,6 +61,7 @@ static param_export_t params[] = {
|
|
||||||
{"keys", PARAM_STRING | PARAM_USE_FUNC, (void *)keys_param},
|
|
||||||
{"schema_path", PARAM_STR, &redis_schema_path},
|
|
||||||
{"verbosity", PARAM_INT, &db_redis_verbosity},
|
|
||||||
+ {"max_key_length", PARAM_INT, &db_redis_max_key_len},
|
|
||||||
#ifdef WITH_SSL
|
|
||||||
{"opt_tls", PARAM_INT, &db_redis_opt_tls},
|
|
||||||
{"ca_path", PARAM_STRING, &db_redis_ca_path},
|
|
||||||
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
|
|
||||||
index b98f401..6725bf5 100644
|
|
||||||
--- a/src/modules/db_redis/redis_dbase.c
|
|
||||||
+++ b/src/modules/db_redis/redis_dbase.c
|
|
||||||
@@ -876,7 +876,7 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
|
||||||
LM_ERR("Failed to add scan command to scan query\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
- if(db_redis_key_add_string(&query_v, index_key->s, index_key->len)
|
|
||||||
+ if(db_redis_key_add_str(&query_v, index_key)
|
|
||||||
!= 0) {
|
|
||||||
LM_ERR("Failed to add scan command to scan query\n");
|
|
||||||
goto err;
|
|
||||||
@@ -891,8 +891,7 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
|
||||||
LM_ERR("Failed to add match command to scan query\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
- if(db_redis_key_add_string(
|
|
||||||
- &query_v, match_pattern->s, match_pattern->len)
|
|
||||||
+ if (db_redis_key_add_str(&query_v, match_pattern)
|
|
||||||
!= 0) {
|
|
||||||
LM_ERR("Failed to add match pattern to scan query\n");
|
|
||||||
goto err;
|
|
||||||
@@ -907,7 +906,7 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con,
|
|
||||||
LM_ERR("Failed to print integer for scan query\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
- if(db_redis_key_add_string(&query_v, match_count_str, l) != 0) {
|
|
||||||
+ if(db_redis_key_add_string(&query_v, match_count_str, (size_t)l) != 0) {
|
|
||||||
LM_ERR("Failed to add count value to scan query\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
diff --git a/src/modules/db_redis/redis_table.c b/src/modules/db_redis/redis_table.c
|
|
||||||
index af3700d..2100884 100644
|
|
||||||
--- a/src/modules/db_redis/redis_table.c
|
|
||||||
+++ b/src/modules/db_redis/redis_table.c
|
|
||||||
@@ -24,14 +24,24 @@
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
-#include "db_redis_mod.h"
|
|
||||||
-#include "redis_connection.h"
|
|
||||||
#include "redis_table.h"
|
|
||||||
|
|
||||||
-int db_redis_key_add_string(redis_key_t **list, const char *entry, int len)
|
|
||||||
+extern unsigned int db_redis_max_key_len;
|
|
||||||
+
|
|
||||||
+int db_redis_key_add_string(redis_key_t **list, const char *entry, size_t len)
|
|
||||||
{
|
|
||||||
redis_key_t *k;
|
|
||||||
|
|
||||||
+ if (!entry || !len) {
|
|
||||||
+ LM_ERR("Empty entry or zero length\n");
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (db_redis_max_key_len > 0 && len > db_redis_max_key_len) {
|
|
||||||
+ LM_ERR("Too big length for key being added: allowed '%u' / given '%zu'\n",
|
|
||||||
+ db_redis_max_key_len, len);
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
k = (redis_key_t *)pkg_malloc(sizeof(redis_key_t));
|
|
||||||
if(!k) {
|
|
||||||
@@ -69,13 +79,26 @@ err:
|
|
||||||
|
|
||||||
int db_redis_key_add_str(redis_key_t **list, const str *entry)
|
|
||||||
{
|
|
||||||
- return db_redis_key_add_string(list, entry->s, entry->len);
|
|
||||||
+ if (entry->len < 0)
|
|
||||||
+ return -1;
|
|
||||||
+ return db_redis_key_add_string(list, entry->s, (size_t)entry->len);
|
|
||||||
}
|
|
||||||
|
|
||||||
-int db_redis_key_prepend_string(redis_key_t **list, const char *entry, int len)
|
|
||||||
+int db_redis_key_prepend_string(redis_key_t **list, const char *entry, size_t len)
|
|
||||||
{
|
|
||||||
redis_key_t *k;
|
|
||||||
|
|
||||||
+ if (!entry || !len) {
|
|
||||||
+ LM_ERR("Empty entry or zero length\n");
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (db_redis_max_key_len > 0 && len > db_redis_max_key_len) {
|
|
||||||
+ LM_ERR("Too big length for key being prepended: allowed '%u' / given '%zu'\n",
|
|
||||||
+ db_redis_max_key_len, len);
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
k = (redis_key_t *)pkg_malloc(sizeof(redis_key_t));
|
|
||||||
if(!k) {
|
|
||||||
LM_ERR("Failed to allocate memory for key list entry\n");
|
|
||||||
diff --git a/src/modules/db_redis/redis_table.h b/src/modules/db_redis/redis_table.h
|
|
||||||
index 6ba4e8c..879b50c 100644
|
|
||||||
--- a/src/modules/db_redis/redis_table.h
|
|
||||||
+++ b/src/modules/db_redis/redis_table.h
|
|
||||||
@@ -61,9 +61,9 @@ void db_redis_free_tables(km_redis_con_t *con);
|
|
||||||
int db_redis_parse_schema(km_redis_con_t *con);
|
|
||||||
int db_redis_parse_keys(km_redis_con_t *con);
|
|
||||||
|
|
||||||
-int db_redis_key_add_string(redis_key_t **list, const char *entry, int len);
|
|
||||||
+int db_redis_key_add_string(redis_key_t **list, const char *entry, size_t len);
|
|
||||||
int db_redis_key_add_str(redis_key_t **list, const str *entry);
|
|
||||||
-int db_redis_key_prepend_string(redis_key_t **list, const char *entry, int len);
|
|
||||||
+int db_redis_key_prepend_string(redis_key_t **list, const char *entry, size_t len);
|
|
||||||
int db_redis_key_list2arr(redis_key_t *list, char ***arr);
|
|
||||||
redis_key_t *db_redis_key_shift(redis_key_t **list);
|
|
||||||
void db_redis_key_free(redis_key_t **list);
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
--- a/src/modules/db_redis/redis_table.c
|
|
||||||
+++ b/src/modules/db_redis/redis_table.c
|
|
||||||
@@ -32,11 +32,6 @@ int db_redis_key_add_string(redis_key_t
|
|
||||||
{
|
|
||||||
redis_key_t *k;
|
|
||||||
|
|
||||||
- if (!entry || !len) {
|
|
||||||
- LM_ERR("Empty entry or zero length\n");
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
if (db_redis_max_key_len > 0 && len > db_redis_max_key_len) {
|
|
||||||
LM_ERR("Too big length for key being added: allowed '%u' / given '%zu'\n",
|
|
||||||
db_redis_max_key_len, len);
|
|
||||||
@@ -56,8 +51,14 @@ int db_redis_key_add_string(redis_key_t
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
- memcpy(k->key.s, entry, len);
|
|
||||||
- k->key.s[len] = '\0';
|
|
||||||
+ /* run memcpy only on non-NULL pointer, because in fact it may happen
|
|
||||||
+ * it comes here empty and with len = 0, this is then an implicit
|
|
||||||
+ * conversion of <null> redis key value into the empty "" string.
|
|
||||||
+ * see `db_redis_val2str()`
|
|
||||||
+ * This is the allowed behavior, but avoid then running memcpy() on it. */
|
|
||||||
+ if (entry && len > 0)
|
|
||||||
+ memcpy(k->key.s, entry, len);
|
|
||||||
+ k->key.s[len] = '\0'; /* at least 1 byte is already pre-allocated before */
|
|
||||||
k->key.len = len;
|
|
||||||
|
|
||||||
if(!*list) {
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Tue, 27 May 2025 10:52:57 +0200
|
|
||||||
Subject: permissions: don't allow reloads in the middle of ongoind reload
|
|
||||||
|
|
||||||
---
|
|
||||||
src/modules/permissions/rpc.c | 13 ++++++++++---
|
|
||||||
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/modules/permissions/rpc.c b/src/modules/permissions/rpc.c
|
|
||||||
index 6519c63..ae78aa4 100644
|
|
||||||
--- a/src/modules/permissions/rpc.c
|
|
||||||
+++ b/src/modules/permissions/rpc.c
|
|
||||||
@@ -45,7 +45,8 @@ int rpc_check_reload(rpc_t *rpc, void *ctx)
|
|
||||||
rpc->fault(ctx, 500, "ongoing reload");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
- *perm_rpc_reload_time = time(NULL);
|
|
||||||
+ // we are reloading
|
|
||||||
+ *perm_rpc_reload_time = time(NULL) + 86400;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -61,10 +62,13 @@ void rpc_trusted_reload(rpc_t *rpc, void *c)
|
|
||||||
|
|
||||||
if(reload_trusted_table_cmd() != 1) {
|
|
||||||
rpc->fault(c, 500, "Reload failed.");
|
|
||||||
- return;
|
|
||||||
+ goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc->rpl_printf(c, "Reload OK");
|
|
||||||
+done:
|
|
||||||
+ // reloading is done
|
|
||||||
+ *perm_rpc_reload_time = time(NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -101,10 +105,13 @@ void rpc_address_reload(rpc_t *rpc, void *c)
|
|
||||||
|
|
||||||
if(reload_address_table_cmd() != 1) {
|
|
||||||
rpc->fault(c, 500, "Reload failed.");
|
|
||||||
- return;
|
|
||||||
+ goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc->rpl_printf(c, "Reload OK");
|
|
||||||
+done:
|
|
||||||
+ // reloading is done
|
|
||||||
+ *perm_rpc_reload_time = time(NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
--- a/src/modules/rtpengine/rtpengine.c
|
|
||||||
+++ b/src/modules/rtpengine/rtpengine.c
|
|
||||||
@@ -2992,6 +2992,8 @@
|
|
||||||
if(ng_flags->to && ng_flags->to_tag.s && ng_flags->to_tag.len)
|
|
||||||
bencode_dictionary_add_str(
|
|
||||||
ng_flags->dict, "to-tag", &ng_flags->to_tag);
|
|
||||||
+ if(ng_flags->flags)
|
|
||||||
+ bencode_list_add_string(ng_flags->flags, "directional");
|
|
||||||
}
|
|
||||||
} else if(op == OP_SUBSCRIBE_REQUEST || op == OP_UNSUBSCRIBE) {
|
|
||||||
bencode_dictionary_add_str(
|
|
||||||
Loading…
Reference in new issue