From df81958258a7a5a3e537f8f4fdf92e350ac8f0fe Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Feb 13 2018 13:45:07 +0000 Subject: Ver. 2.2.6 Signed-off-by: Peter Lemenkov --- diff --git a/.gitignore b/.gitignore index 2a62bd0..dfb3e3a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ opensips-1.6.3-tls_src.tar.gz /opensips-2.2.2.tar.gz /opensips-2.2.3.tar.gz /opensips-2.2.5.tar.gz +/opensips-2.2.6.tar.gz diff --git a/opensips-0008-Dont-try-modifying-CFLAGS.patch b/opensips-0008-Dont-try-modifying-CFLAGS.patch index 370d107..1c2ab4c 100644 --- a/opensips-0008-Dont-try-modifying-CFLAGS.patch +++ b/opensips-0008-Dont-try-modifying-CFLAGS.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Dont' try modifying CFLAGS Signed-off-by: Peter Lemenkov diff --git a/Makefile.defs b/Makefile.defs -index 144b7e9da..38a0376e5 100644 +index 3081dc26b..f7097b39f 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -763,526 +763,8 @@ endif diff --git a/opensips-0009-Add-support-for-openssl-1.1.0.patch b/opensips-0009-Add-support-for-openssl-1.1.0.patch index d1d508c..074029a 100644 --- a/opensips-0009-Add-support-for-openssl-1.1.0.patch +++ b/opensips-0009-Add-support-for-openssl-1.1.0.patch @@ -127,7 +127,7 @@ index acb5c66fa..ca901bde6 100644 if ( c->proto_flags & F_TLS_DO_ACCEPT ) { diff --git a/modules/tls_mgm/tls_conn_server.h b/modules/tls_mgm/tls_conn_server.h -index 4a4fe7a78..240963271 100644 +index 8812f1db1..af6c2b309 100644 --- a/modules/tls_mgm/tls_conn_server.h +++ b/modules/tls_mgm/tls_conn_server.h @@ -148,16 +148,20 @@ static int tls_accept(struct tcp_connection *c, short *poll_events) diff --git a/opensips-0013-Fix-milliseconds-for-call-duration-consistency-acros.patch b/opensips-0013-Fix-milliseconds-for-call-duration-consistency-acros.patch deleted file mode 100644 index 76774b1..0000000 --- a/opensips-0013-Fix-milliseconds-for-call-duration-consistency-acros.patch +++ /dev/null @@ -1,249 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Thu, 6 Jul 2017 14:49:05 +0300 -Subject: [PATCH] Fix milliseconds (for call duration) consistency across ACC - backends. - -Each backend was evaluating the END time by itself, leading to discrepencies in the reported milliseconds between different backends (when multiple backends were used for CDR reporting). -The fix consists in having a single END time value shared to all ACC backends. - -diff --git a/modules/acc/acc.c b/modules/acc/acc.c -index 673f1b795..d06370389 100644 ---- a/modules/acc/acc.c -+++ b/modules/acc/acc.c -@@ -264,19 +264,18 @@ void acc_log_init(void) - SET_LOG_ATTR(n,CREATED); - } - --int acc_log_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) -+int acc_log_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end) - { - static char log_msg[MAX_SYSLOG_SIZE]; - static char *log_msg_end=log_msg+MAX_SYSLOG_SIZE-2; - char *p; - int nr_vals, i, j, ret, res = -1, n; - time_t created; -- struct timeval start_time,end; -+ struct timeval start_time; - str core_s, leg_s, extra_s; - short nr_legs; - -- gettimeofday(&end,NULL); -- - core_s.s = extra_s.s = leg_s.s = 0; - - ret = prebuild_core_arr(dlg, &core_s, &start_time); -@@ -368,8 +367,8 @@ int acc_log_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) - "%.*screated=%lu;call_start_time=%lu;duration=%lu;ms_duration=%lu;setuptime=%lu%s", - acc_env.text.len, acc_env.text.s,(unsigned long)created, - (unsigned long)start_time.tv_sec, -- (unsigned long)(end.tv_sec-start_time.tv_sec), -- (unsigned long)((end.tv_sec-start_time.tv_sec)*1000+(end.tv_usec-start_time.tv_usec)%1000), -+ (unsigned long)(end->tv_sec-start_time.tv_sec), -+ (unsigned long)((end->tv_sec-start_time.tv_sec)*1000+(end->tv_usec-start_time.tv_usec)%1000), - (unsigned long)(start_time.tv_sec - created), log_msg); - - res = 1; -@@ -668,12 +667,13 @@ int acc_db_request( struct sip_msg *rq, struct sip_msg *rpl, - return 1; - } - --int acc_db_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) -+int acc_db_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end) - { - int total, nr_vals, i, ret, res = -1, nr_bye_vals = 0, j; - int remaining_bye_vals = 0; - time_t created; -- struct timeval start_time,end; -+ struct timeval start_time; - str core_s, leg_s, extra_s, table; - short nr_legs; - static db_ps_t my_ps = NULL; -@@ -685,7 +685,6 @@ int acc_db_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) - } - - core_s.s = extra_s.s = leg_s.s = 0; -- gettimeofday(&end,NULL); - - ret = prebuild_core_arr(dlg, &core_s, &start_time); - if (ret < 0) { -@@ -729,9 +728,9 @@ int acc_db_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) - VAL_TIME(db_vals_cdrs+ACC_CORE_LEN) = start_time.tv_sec; - VAL_INT(db_vals_cdrs+ret+nr_vals+nr_bye_vals+1) = start_time.tv_sec - created; - VAL_TIME(db_vals_cdrs+ret+nr_vals+nr_bye_vals+2) = created; -- VAL_INT(db_vals_cdrs+ret+nr_vals+nr_bye_vals+3) = end.tv_sec - start_time.tv_sec; -+ VAL_INT(db_vals_cdrs+ret+nr_vals+nr_bye_vals+3) = end->tv_sec - start_time.tv_sec; - VAL_INT(db_vals_cdrs+ret+nr_vals+nr_bye_vals+4) = -- (end.tv_sec-start_time.tv_sec)*1000+(end.tv_usec-start_time.tv_usec)%1000; -+ (end->tv_sec-start_time.tv_sec)*1000+(end->tv_usec-start_time.tv_usec)%1000; - - total = ret + 5; - acc_dbf.use_table(db_handle, &table); -@@ -982,18 +981,18 @@ error: - return -1; - } - --int acc_aaa_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) -+int acc_aaa_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end) - { - int nr_vals, i, j, ret, res = -1; - time_t created; -- struct timeval start_time,end; -+ struct timeval start_time; - str core_s, leg_s, extra_s; - short nr_legs; - aaa_message *send = NULL; - int offset, av_type; - aaa_map *r_stat; - -- gettimeofday(&end,NULL); - core_s.s = extra_s.s = leg_s.s = 0; - - ret = prebuild_core_arr(dlg, &core_s, &start_time); -@@ -1053,9 +1052,9 @@ int acc_aaa_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) - offset = ret + 2; - - /* add duration and setup values */ -- av_type = (uint32_t)(end.tv_sec - start_time.tv_sec); -+ av_type = (uint32_t)(end->tv_sec - start_time.tv_sec); - ADD_AAA_AVPAIR( offset + nr_vals, &av_type, -1); -- av_type = (uint32_t)((end.tv_sec-start_time.tv_sec)*1000+(end.tv_usec-start_time.tv_usec)%1000); -+ av_type = (uint32_t)((end->tv_sec-start_time.tv_sec)*1000+(end->tv_usec-start_time.tv_usec)%1000); - ADD_AAA_AVPAIR( offset + nr_vals + 1, &av_type, -1); - av_type = (uint32_t)(start_time.tv_sec - created); - ADD_AAA_AVPAIR( offset + nr_vals + 2, &av_type, -1); -@@ -1529,12 +1528,13 @@ end: - return ret; - } - --int acc_evi_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) -+int acc_evi_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end) - { - int nr_vals, i, ret, res = -1, nr_bye_vals = 0, j; - int aux_time; - time_t created; -- struct timeval start_time,end; -+ struct timeval start_time; - str core_s, leg_s, extra_s; - short nr_legs; - -@@ -1547,7 +1547,6 @@ int acc_evi_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) - if (!evi_probe_event(acc_cdr_event)) - return 1; - -- gettimeofday(&end,NULL); - core_s.s = extra_s.s = leg_s.s = 0; - - ret = prebuild_core_arr(dlg, &core_s, &start_time); -@@ -1597,12 +1596,13 @@ int acc_evi_cdrs(struct dlg_cell *dlg, struct sip_msg *msg) - LM_ERR("cannot set start_time parameter\n"); - goto end; - } -- aux_time = end.tv_sec - start_time.tv_sec; -+ aux_time = end->tv_sec - start_time.tv_sec; - if (evi_param_set_int(evi_params[ret+nr_vals+nr_bye_vals+1], &aux_time) < 0) { - LM_ERR("cannot set duration parameter\n"); - goto end; - } -- aux_time = (end.tv_sec-start_time.tv_sec)*1000+(end.tv_usec-start_time.tv_usec)%1000; -+ aux_time = (end->tv_sec-start_time.tv_sec)*1000 -+ + (end->tv_usec-start_time.tv_usec)%1000; - if (evi_param_set_int(evi_params[ret+nr_vals+nr_bye_vals+2], &aux_time) < 0) { - LM_ERR("cannot set duration parameter\n"); - goto end; -diff --git a/modules/acc/acc.h b/modules/acc/acc.h -index 878fc77f3..2be0fabd1 100644 ---- a/modules/acc/acc.h -+++ b/modules/acc/acc.h -@@ -81,7 +81,8 @@ extern struct dlg_binds dlg_api; - - void acc_log_init(); - int acc_log_request( struct sip_msg *req, struct sip_msg *rpl, int cdr_flag); --int acc_log_cdrs(struct dlg_cell *dlg, struct sip_msg *msg); -+int acc_log_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end); - int store_log_extra_values(struct dlg_cell *dlg, struct sip_msg *req, - struct sip_msg *reply); - -@@ -90,14 +91,16 @@ int acc_db_init_child(const str* db_url); - void acc_db_close(); - int acc_db_request( struct sip_msg *req, struct sip_msg *rpl, - query_list_t **ins_list, int cdr_flag); --int acc_db_cdrs(struct dlg_cell *dlg, struct sip_msg *msg); -+int acc_db_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end); - int store_db_extra_values(struct dlg_cell *dlg, struct sip_msg *req, - struct sip_msg *reply); - - int init_acc_aaa(char* aaa_proto_url, int srv_type); - int acc_aaa_request( struct sip_msg *req, struct sip_msg *rpl, int cdr_flag); - int acc_aaa_cdrs_request(struct dlg_cell *dlg); --int acc_aaa_cdrs(struct dlg_cell *dlg, struct sip_msg *msg); -+int acc_aaa_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end); - int store_aaa_extra_values(struct dlg_cell *dlg, struct sip_msg *req, - struct sip_msg *reply); - -@@ -107,7 +110,8 @@ int create_acc_dlg(struct sip_msg* req); - - int init_acc_evi(void); - int acc_evi_request( struct sip_msg *req, struct sip_msg *rpl, int cdr_flag); --int acc_evi_cdrs(struct dlg_cell *dlg, struct sip_msg *msg); -+int acc_evi_cdrs(struct dlg_cell *dlg, struct sip_msg *msg, -+ struct timeval *end); - int store_evi_extra_values(struct dlg_cell *dlg, struct sip_msg *req, - struct sip_msg *reply); - extern event_id_t acc_cdr_event; -diff --git a/modules/acc/acc_logic.c b/modules/acc/acc_logic.c -index a92acdf74..6d21f676f 100644 ---- a/modules/acc/acc_logic.c -+++ b/modules/acc/acc_logic.c -@@ -739,6 +739,7 @@ static void acc_dlg_callback(struct dlg_cell *dlg, int type, - struct dlg_cb_params *_params) - { - unsigned long long flags; -+ struct timeval end; - - if (!_params) { - LM_ERR("not enough info\n"); -@@ -764,9 +765,11 @@ static void acc_dlg_callback(struct dlg_cell *dlg, int type, - */ - set_dlg_cb_used(*((unsigned long long*)*_params->param)); - -+ gettimeofday(&end,NULL); -+ - if (is_evi_acc_on(flags)) { - env_set_event(acc_cdr_event); -- if (acc_evi_cdrs(dlg, _params->msg) < 0) { -+ if (acc_evi_cdrs(dlg, _params->msg, &end) < 0) { - LM_ERR("cannot send accounting events\n"); - return; - } -@@ -774,7 +777,7 @@ static void acc_dlg_callback(struct dlg_cell *dlg, int type, - - if (is_log_acc_on(flags)) { - env_set_text( ACC_ENDED, ACC_ENDED_LEN); -- if (acc_log_cdrs(dlg, _params->msg) < 0) { -+ if (acc_log_cdrs(dlg, _params->msg, &end) < 0) { - LM_ERR("Cannot log values\n"); - return; - } -@@ -782,13 +785,13 @@ static void acc_dlg_callback(struct dlg_cell *dlg, int type, - - if (is_db_acc_on(flags)) { - env_set_text( db_table_acc.s, db_table_acc.len); -- if (acc_db_cdrs(dlg, _params->msg) < 0) { -+ if (acc_db_cdrs(dlg, _params->msg, &end) < 0) { - LM_ERR("Cannot insert into database\n"); - return; - } - } - -- if (is_aaa_acc_on(flags) && acc_aaa_cdrs(dlg, _params->msg) < 0) { -+ if (is_aaa_acc_on(flags) && acc_aaa_cdrs(dlg, _params->msg, &end) < 0) { - LM_ERR("Cannot create radius accounting\n"); - return; - } diff --git a/opensips-0013-modules-json-Properly-detect-json-c-version-and-adap.patch b/opensips-0013-modules-json-Properly-detect-json-c-version-and-adap.patch new file mode 100644 index 0000000..526b6c3 --- /dev/null +++ b/opensips-0013-modules-json-Properly-detect-json-c-version-and-adap.patch @@ -0,0 +1,245 @@ +From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= +Date: Tue, 12 Dec 2017 15:31:53 +0100 +Subject: [PATCH] modules/json: Properly detect json-c version and adaptions + for v0.13 + + +diff --git a/modules/json/Makefile b/modules/json/Makefile +index 5c514655b..479bec701 100644 +--- a/modules/json/Makefile ++++ b/modules/json/Makefile +@@ -2,7 +2,7 @@ + # + # Memcached implementation for memcache API. + # +-# ++# + # WARNING: do not run this directly, it should be run by the master Makefile + + include ../../Makefile.defs +@@ -23,8 +23,23 @@ ifeq ($(JSON_BUILDER),) + DEFS += -I$(LOCALBASE)/include -I$(SYSBASE)/include + LIBS += -L$(LOCALBASE)/lib -ljson + else +- JSON_LIB_VER = $(shell $(JSON_BUILDER) --modversion | sed "s/\.\([0-9]\)\./.0\1./g" | sed "s/\.\([0-9]\)\$$/.0\1/g" | tr -d "." | sed -e "s/^0*//" ) +- DEFS += $(shell $(JSON_BUILDER) --cflags) -DJSON_LIB_VERSION=$(JSON_LIB_VER) ++ JSON_PKG_VER = $(shell $(JSON_BUILDER) --modversion) ++ JSON_PKG_MAJOR = $(shell \ ++ ver_tmp=`echo '$(JSON_PKG_VER)' | cut -f1 -d.`; \ ++ if [ -z "$$ver_tmp" ]; then ver_tmp=0; fi; \ ++ echo "$$ver_tmp";) ++ JSON_PKG_MINOR = $(shell \ ++ ver_tmp=`echo '$(JSON_PKG_VER)' | cut -f2 -d.`; \ ++ if [ -z "$$ver_tmp" ]; then ver_tmp=0; fi; \ ++ echo "$$ver_tmp";) ++ JSON_PKG_MICRO = $(shell \ ++ ver_tmp=`echo '$(JSON_PKG_VER)' | cut -f3 -d.`; \ ++ if [ -z "$$ver_tmp" ]; then ver_tmp=0; fi; \ ++ echo "$$ver_tmp";) ++ DEFS += $(shell $(JSON_BUILDER) --cflags) \ ++ -DJSON_PKG_MAJOR=$(JSON_PKG_MAJOR) \ ++ -DJSON_PKG_MINOR=$(JSON_PKG_MINOR) \ ++ -DJSON_PKG_MICRO=$(JSON_PKG_MICRO) + LIBS += $(shell $(JSON_BUILDER) --libs) + endif + +diff --git a/modules/json/array_del.c b/modules/json/array_del.c +index b23f6d3b3..9be6e2f84 100644 +--- a/modules/json/array_del.c ++++ b/modules/json/array_del.c +@@ -22,27 +22,34 @@ + * History: + * --------- + * 2009-09-04 first version (andreidragus) ++ * 2017-12-12 use opensips_json_c_helper.h (besser82) + */ + +-#include +-#include ++#include "opensips_json_c_helper.h" + +-void array_list_del_idx( struct array_list * arr, int idx) ++#if JSON_C_VERSION_NUM < JSON_C_VER_013 ++void array_list_del_idx(struct array_list * arr, int idx) + { + int i; + +- if( idx >= arr->length) ++ if(idx >= arr->length) + return; + + + arr->free_fn(arr->array[idx]); + arr->length--; + +- for( i=idx; ilength; i++ ) ++ for(i=idx; ilength; i++) + arr->array[i] = arr->array[i+1]; + }; ++#endif + + void json_object_array_del(struct json_object* obj, int idx) + { ++#if JSON_C_VERSION_NUM >= JSON_C_VER_013 ++ struct array_list * arr = json_object_get_array(obj); ++ array_list_del_idx(arr, idx, arr->length); ++#else + array_list_del_idx(obj->o.c_array, idx); ++#endif + }; +diff --git a/modules/json/json.c b/modules/json/json.c +index ee3671e87..b5e21c3dd 100644 +--- a/modules/json/json.c ++++ b/modules/json/json.c +@@ -22,6 +22,7 @@ + * History: + * --------- + * 2009-09-04 first version (andreidragus) ++ * 2017-12-12 use opensips_json_c_helper.h (besser82) + */ + + +@@ -43,14 +44,9 @@ + #include "../../mi/mi.h" + #include "../tm/tm_load.h" + #include "../rr/api.h" ++#include "opensips_json_c_helper.h" + + +-#include +-#include +- +- +-#define JSON_BUFF_SIZE 4096 +- + enum + { + TAG_KEY = 1, +@@ -93,7 +89,7 @@ typedef struct _json_name + }json_name; + + pv_json_t * all; +-char buff[JSON_BUFF_SIZE]; ++char buff[JSON_FILE_BUF_SIZE]; + + static int mod_init(void); + static int child_init(int ); +@@ -297,19 +293,16 @@ json_t * get_object(pv_json_t * var, pv_param_t* pvp , json_tag ** tag, + !json_object_is_type( cur_obj, json_type_object ) ) + goto error; + +-#if JSON_LIB_VERSION < 10 ++#if JSON_C_VERSION_NUM >= JSON_C_VER_010 ++ if (!json_object_object_get_ex( cur_obj,buff, &cur_obj ) && ++ tag == NULL) ++ goto error; ++#else + cur_obj = json_object_object_get( cur_obj, buff ); + + if( cur_obj == NULL && tag == NULL) + goto error; +-#else +- if (!json_object_object_get_ex( cur_obj,buff, &cur_obj ) && +- tag == NULL) +- goto error; + #endif +- +- +- + } + + if( cur_tag->type & TAG_IDX ) +@@ -417,7 +410,7 @@ int pv_get_json (struct sip_msg* msg, pv_param_t* pvp, pv_value_t* val) + { + val->flags = PV_VAL_STR; + val->rs.s = (char*)json_object_get_string( obj ); +-#if JSON_LIB_VERSION >= 10 ++#if JSON_C_VERSION_NUM >= JSON_C_VER_010 + val->rs.len = json_object_get_string_len( obj ); + #else + val->rs.len = strlen(val->rs.s); +@@ -589,7 +582,7 @@ int pv_set_json (struct sip_msg* msg, pv_param_t* pvp, int flag , + if (obj == NULL) + { + LM_ERR("Error parsing json: %s\n", +-#if JSON_LIB_VERSION >= 10 ++#if JSON_C_VERSION_NUM >= JSON_C_VER_010 + json_tokener_error_desc(parse_status) + #else + json_tokener_errors[(unsigned long)obj] +diff --git a/modules/json/opensips_json_c_helper.h b/modules/json/opensips_json_c_helper.h +new file mode 100644 +index 000000000..71c5c2189 +--- /dev/null ++++ b/modules/json/opensips_json_c_helper.h +@@ -0,0 +1,70 @@ ++/* ++ * Copyright (C) 2017 Björn Esser ++ * ++ * This file is part of opensips, a free SIP server. ++ * ++ * opensips is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * opensips is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ * ++ * History: ++ * --------- ++ * 2017-12-12 first version (besser82) ++ */ ++ ++#ifndef OPENSIPS_JSON_C_HELPER_H ++#define OPENSIPS_JSON_C_HELPER_H ++ ++// If those are not defined, we assume to build against json-c v0.9. ++// Starting with v0.11 there is json_c_version.h, which we prefer ++// anyways, so there are no regressions in this case. Everything ++// conditionalized for v0.10 or later doesn't produce any fallout, ++// when we are asuming v0.9 and building against v0.10. ++#ifndef JSON_PKG_MAJOR ++#define JSON_PKG_MAJOR 0 ++#endif ++#ifndef JSON_PKG_MINOR ++#define JSON_PKG_MINOR 9 ++#endif ++#ifndef JSON_PKG_MICRO ++#define JSON_PKG_MICRO 0 ++#endif ++ ++// json.h automatically includes json_c_version.h, if available. ++#include ++ ++// We prefer JSON_C_VERSION_NUM defined in json_c_version.h. If it is ++// not defined, we construct it the same way from our JSON_PKG_* defines. ++#ifndef JSON_C_VERSION_NUM ++#define JSON_C_VERSION_NUM (JSON_PKG_MAJOR << 16) | \ ++ (JSON_PKG_MINOR << 8) | \ ++ JSON_PKG_MICRO ++#endif ++ ++// Macros for checking specific versions. ++#define JSON_C_VER_010 (10 << 8) ++#define JSON_C_VER_013 (13 << 8) ++ ++// json_object_private.h is gone and not needed anymore in json-c v0.13+. ++#if JSON_C_VERSION_NUM < JSON_C_VER_013 ++#include ++#endif ++ ++// Newer versions of json-c define this in their headers, so we prefer ++// their definition in that case. ++#ifndef JSON_FILE_BUF_SIZE ++#define JSON_FILE_BUF_SIZE 4096 ++#endif ++ ++#endif // OPENSIPS_JSON_C_HELPER_H diff --git a/opensips-0014-Add-sys-uio.h-where-writev-2-is-used.patch b/opensips-0014-Add-sys-uio.h-where-writev-2-is-used.patch new file mode 100644 index 0000000..45d3f85 --- /dev/null +++ b/opensips-0014-Add-sys-uio.h-where-writev-2-is-used.patch @@ -0,0 +1,89 @@ +From: Maksym Sobolyev +Date: Mon, 13 Feb 2017 18:54:55 -0800 +Subject: [PATCH] Add where writev(2) is used. + + +diff --git a/modules/cpl_c/cpl_loader.c b/modules/cpl_c/cpl_loader.c +index ef9b87362..864a937be 100644 +--- a/modules/cpl_c/cpl_loader.c ++++ b/modules/cpl_c/cpl_loader.c +@@ -33,7 +33,6 @@ + #include + #include + #include +-#include + #include + #include + #include +diff --git a/modules/db_flatstore/flatstore.c b/modules/db_flatstore/flatstore.c +index 164a6e194..2239353a4 100644 +--- a/modules/db_flatstore/flatstore.c ++++ b/modules/db_flatstore/flatstore.c +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + #include + #include "../../mem/mem.h" + #include "../../dprint.h" +diff --git a/modules/event_flatstore/event_flatstore.c b/modules/event_flatstore/event_flatstore.c +index cff08274a..0ad2a2879 100644 +--- a/modules/event_flatstore/event_flatstore.c ++++ b/modules/event_flatstore/event_flatstore.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + #include "event_flatstore.h" + #include "../../mem/mem.h" +diff --git a/modules/event_xmlrpc/xmlrpc_send.c b/modules/event_xmlrpc/xmlrpc_send.c +index ab1a2601e..19a3f861a 100644 +--- a/modules/event_xmlrpc/xmlrpc_send.c ++++ b/modules/event_xmlrpc/xmlrpc_send.c +@@ -30,6 +30,7 @@ + #include "../../pt.h" + #include "xmlrpc_send.h" + #include "event_xmlrpc.h" ++#include + #include + #include + +diff --git a/modules/proto_ws/proto_ws.c b/modules/proto_ws/proto_ws.c +index 7c041b953..313755a2a 100644 +--- a/modules/proto_ws/proto_ws.c ++++ b/modules/proto_ws/proto_ws.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #include + + #include "../../pt.h" +diff --git a/modules/proto_ws/ws_tcp.c b/modules/proto_ws/ws_tcp.c +index 8421d9fe5..7b179b529 100644 +--- a/modules/proto_ws/ws_tcp.c ++++ b/modules/proto_ws/ws_tcp.c +@@ -29,6 +29,7 @@ + #include "../../globals.h" + #include "../../tsend.h" + #include "ws_tcp.h" ++#include + #include + + /************** READ related functions ***************/ +diff --git a/modules/proto_wss/proto_wss.c b/modules/proto_wss/proto_wss.c +index 83c91b6bc..ed207b30a 100644 +--- a/modules/proto_wss/proto_wss.c ++++ b/modules/proto_wss/proto_wss.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #include + + #include "../../pt.h" diff --git a/opensips-0014-acc-restore-new_uri-in-case-an-error-occurs-on-reply.patch b/opensips-0014-acc-restore-new_uri-in-case-an-error-occurs-on-reply.patch deleted file mode 100644 index 59b286a..0000000 --- a/opensips-0014-acc-restore-new_uri-in-case-an-error-occurs-on-reply.patch +++ /dev/null @@ -1,76 +0,0 @@ -From: Razvan Crainea -Date: Wed, 12 Jul 2017 14:47:54 +0300 -Subject: [PATCH] acc: restore new_uri in case an error occurs on reply - -(cherry picked from commit e2f9d8fc73a8414fc80430abd4ba5975cb1bfe89) - -diff --git a/modules/acc/acc_logic.c b/modules/acc/acc_logic.c -index 6d21f676f..47daf4204 100644 ---- a/modules/acc/acc_logic.c -+++ b/modules/acc/acc_logic.c -@@ -653,27 +653,27 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req, - /* if dialog module loaded and INVITE and success reply */ - if (store_core_leg_values(dlg, req) < 0) { - LM_ERR("cannot store core and leg values\n"); -- return; -+ goto restore; - } - - if(is_log_acc_on(*flags) && store_log_extra_values(dlg,req,reply)<0){ - LM_ERR("cannot store string values\n"); -- return; -+ goto restore; - } - - if(is_aaa_acc_on(*flags) && store_aaa_extra_values(dlg, req, reply)<0){ - LM_ERR("cannot store aaa extra values\n"); -- return; -+ goto restore; - } - - if (is_db_acc_on(*flags) && store_db_extra_values(dlg,req,reply)<0) { - LM_ERR("cannot store database extra values\n"); -- return; -+ goto restore; - } - - if (is_evi_acc_on(*flags) && store_evi_extra_values(dlg,req,reply)<0) { - LM_ERR("cannot store database extra values\n"); -- return; -+ goto restore; - } - - flags_s.s = (char*)flags; -@@ -682,13 +682,13 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req, - /* store flags into dlg */ - if ( dlg_api.store_dlg_value(dlg, &flags_str, &flags_s) < 0) { - LM_ERR("cannot store flag value into dialog\n"); -- return; -+ goto restore; - } - - /* store flags into dlg */ - if ( dlg_api.store_dlg_value(dlg, &table_str, &table.s) < 0) { - LM_ERR("cannot store the table name into dialog\n"); -- return; -+ goto restore; - } - - /* report that flags shall be freed only by dialog module -@@ -699,7 +699,7 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req, - if (dlg_api.register_dlgcb(dlg, DLGCB_TERMINATED | - DLGCB_EXPIRED, acc_dlg_callback,flags, dlg_free_acc_mask) != 0) { - LM_ERR("cannot register callback for database accounting\n"); -- return; -+ goto restore; - } - } else { - /* do old accounting */ -@@ -728,6 +728,7 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req, - acc_diam_request( req, reply ); - #endif - -+restore: - if (new_uri_bk.len>=0) { - req->new_uri = new_uri_bk; - req->dst_uri = dst_uri_bk; diff --git a/opensips-0015-drouting-fix-parameters-specifications-for-gw-detect.patch b/opensips-0015-drouting-fix-parameters-specifications-for-gw-detect.patch deleted file mode 100644 index dc74968..0000000 --- a/opensips-0015-drouting-fix-parameters-specifications-for-gw-detect.patch +++ /dev/null @@ -1,29 +0,0 @@ -From: Razvan Crainea -Date: Thu, 13 Jul 2017 14:13:05 +0300 -Subject: [PATCH] drouting: fix parameters specifications for gw detection - functions - -(cherry picked from commit 991b3ef4fabb4a21dd0f95ea18a5e934261be01c) - -diff --git a/modules/drouting/drouting.c b/modules/drouting/drouting.c -index 49c931ea2..a73112e7e 100644 ---- a/modules/drouting/drouting.c -+++ b/modules/drouting/drouting.c -@@ -4286,7 +4286,7 @@ static int goes_to_gw_1(struct sip_msg* msg, char * part, char* _type, char* fla - GET_NEXT_HOP(msg)); - } else { - gw_attrs_spec = (pv_spec_p)flags_pv; -- return _is_dr_uri_gw(msg, NULL, _type, (!part ? -1 : (int)(long)part), -+ return _is_dr_uri_gw(msg, NULL, flags_pv, (!_type ? -1 : (int)(long)_type), - GET_NEXT_HOP(msg)); - } - } -@@ -4325,7 +4325,7 @@ static int dr_is_gw(struct sip_msg* msg, char * part, char* src_pv, char* type_s - return -1; - } - gw_attrs_spec = (pv_spec_p)flags_pv; -- return _is_dr_uri_gw(msg, NULL, type_s ,!src_pv ? -1:(int)(long)src_pv -+ return _is_dr_uri_gw(msg, NULL, flags_pv ,!type_s ? -1:(int)(long)type_s - ,&src.rs); - } - } diff --git a/opensips-0015-sst-fix-MIN-SE-header-printing.patch b/opensips-0015-sst-fix-MIN-SE-header-printing.patch new file mode 100644 index 0000000..09a2452 --- /dev/null +++ b/opensips-0015-sst-fix-MIN-SE-header-printing.patch @@ -0,0 +1,40 @@ +From: Razvan Crainea +Date: Fri, 27 Oct 2017 12:01:36 +0300 +Subject: [PATCH] sst: fix MIN-SE header printing + + +diff --git a/modules/sst/sst_handlers.c b/modules/sst/sst_handlers.c +index d3c2e8a4b..7e3661c0a 100644 +--- a/modules/sst/sst_handlers.c ++++ b/modules/sst/sst_handlers.c +@@ -985,23 +985,17 @@ static int parse_msg_for_sst_info(struct sip_msg *msg, sst_msg_info_t *minfo) + */ + static int send_reject(struct sip_msg *msg, unsigned int min_se) + { +- char tmp[2]; /* to find the length */ ++ char tmp[8 /* "MIN-SE: " */ + INT2STR_MAX_LEN + 2 /* CRLF */ + 1 /* '\0' */]; + int hdr_len = 0; + char *minse_hdr = NULL; + +- hdr_len = snprintf(tmp, 2, "%s %d%s", "MIN-SE:", min_se, CRLF); +- if ((minse_hdr = pkg_malloc(hdr_len+1)) != NULL) { +- memset(minse_hdr, 0, hdr_len+1); +- snprintf(minse_hdr, hdr_len+1, "%s %d%s", "MIN-SE:", min_se, CRLF); +- if (send_response(msg, 422, &sst_422_rpl, minse_hdr, hdr_len)) { +- LM_ERR("Error sending 422 reply.\n"); +- return(-1); +- } +- pkg_free(minse_hdr); +- LM_DBG("Send reject reply 422 with Min-SE: %d\n", min_se); +- return(0); ++ hdr_len = snprintf(tmp, sizeof(tmp), "%s %d%s", "MIN-SE:", min_se, CRLF); ++ if (send_response(msg, 422, &sst_422_rpl, minse_hdr, hdr_len)) { ++ LM_ERR("Error sending 422 reply.\n"); ++ return(-1); + } +- return(-1); ++ LM_DBG("Send reject reply 422 with Min-SE: %d\n", min_se); ++ return(0); + } + + /** diff --git a/opensips-0016-Fix-incorrect-bug-log.patch b/opensips-0016-Fix-incorrect-bug-log.patch deleted file mode 100644 index c023f51..0000000 --- a/opensips-0016-Fix-incorrect-bug-log.patch +++ /dev/null @@ -1,19 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Fri, 14 Jul 2017 18:30:44 +0300 -Subject: [PATCH] Fix incorrect bug log. - -A missing tracing context in the SL_reply_out callback is perfectly valid - if you send from script a reply (se_send_reply) without doing any sip_trace() before. - -diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c -index 885d84ad9..f626e5ab9 100644 ---- a/modules/siptrace/siptrace.c -+++ b/modules/siptrace/siptrace.c -@@ -1663,7 +1663,7 @@ static void trace_slreply_out(struct sip_msg* req, str *buffer,int rpl_code, - - info = context_get_ptr(CONTEXT_GLOBAL, current_processing_ctx, sl_ctx_idx); - if (info == NULL) { -- LM_BUG("null trace info!something is wrong here \n"); -+ LM_DBG("no sip_trace() done so far\n"); - return; - } - diff --git a/opensips-0016-sms-prevent-buffer-overrun.patch b/opensips-0016-sms-prevent-buffer-overrun.patch new file mode 100644 index 0000000..84c3bd3 --- /dev/null +++ b/opensips-0016-sms-prevent-buffer-overrun.patch @@ -0,0 +1,60 @@ +From: Razvan Crainea +Date: Mon, 24 Oct 2016 18:11:07 +0300 +Subject: [PATCH] sms: prevent buffer overrun + +Fixes Coverity CID 40783 and 40784 and 40875 + +diff --git a/modules/sms/libsms_getsms.c b/modules/sms/libsms_getsms.c +index 71ff9df5f..26f6b57a2 100644 +--- a/modules/sms/libsms_getsms.c ++++ b/modules/sms/libsms_getsms.c +@@ -275,13 +275,15 @@ static int splitascii(struct modem *mdm, char *source, struct incame_sms *sms) + { + char* start; + char* end; ++ char tbuf[TIME_LEN + 1]; ++ char dbuf[DATE_LEN + 1]; + + /* the text is after the \r */ + for( start=source ; *start && *start!='\r' ; start++ ); + if (!*start) + return 1; + start++; +- strcpy(sms->ascii,start); ++ strncpy(sms->ascii,start,500); + /* get the senders MSISDN */ + start=strstr(source,"\",\""); + if (start==0) { +@@ -295,7 +297,7 @@ static int splitascii(struct modem *mdm, char *source, struct incame_sms *sms) + return 1; + } + *end=0; +- strcpy(sms->sender,start); ++ strncpy(sms->sender,start,500); + /* Siemens M20 inserts the senders name between MSISDN and date */ + start=end+3; + // Workaround for Thomas Stoeckel // +@@ -308,16 +310,18 @@ static int splitascii(struct modem *mdm, char *source, struct incame_sms *sms) + return 1; + } + *end=0; +- strcpy(sms->name,start); ++ strncpy(sms->name,start,500); + } + /* Get the date */ + start=end+3; +- sprintf(sms->date,"%c%c-%c%c-%c%c",start[3],start[4],start[0],start[1], +- start[6],start[7]); ++ snprintf(dbuf, DATE_LEN + 1, "%c%c-%c%c-%c%c",start[3],start[4], ++ start[0],start[1],start[6],start[7]); ++ memcpy(sms->date, dbuf, DATE_LEN); + /* Get the time */ + start+=9; +- sprintf(sms->time,"%c%c:%c%c:%c%c",start[0],start[1],start[3],start[4], +- start[7],start[7]); ++ snprintf(tbuf, TIME_LEN + 1, "%c%c:%c%c:%c%c",start[0],start[1], ++ start[3],start[4],start[7],start[7]); ++ memcpy(sms->time, tbuf, TIME_LEN); + sms->userdatalength=strlen(sms->ascii); + return 1; + } diff --git a/opensips-0017-Fix-replicating-NULL-socket-in-contact.patch b/opensips-0017-Fix-replicating-NULL-socket-in-contact.patch deleted file mode 100644 index 4711310..0000000 --- a/opensips-0017-Fix-replicating-NULL-socket-in-contact.patch +++ /dev/null @@ -1,100 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Mon, 17 Jul 2017 13:38:44 +0300 -Subject: [PATCH] Fix replicating NULL socket in contact - -A contact added by ul_add MI contact has a NULL contact, so take care on this during contact replication. Also, when receiving a replicated contact with NULL socket, do not discard it, but simply set NULL socket. - -Reported by Samusenko Andrej on user mailing list - -(cherry picked from commit d1d897ebc1f7cdd0c817952c28d5c5877b51f304) - -diff --git a/modules/usrloc/ureplication.c b/modules/usrloc/ureplication.c -index b4b68295e..90670f215 100644 ---- a/modules/usrloc/ureplication.c -+++ b/modules/usrloc/ureplication.c -@@ -98,7 +98,7 @@ void replicate_ucontact_insert(urecord_t *r, str *contact, ucontact_info_t *ci) - st.len = sizeof ci->q; - bin_push_str(&st); - -- bin_push_str(&ci->sock->sock_str); -+ bin_push_str(ci->sock?&ci->sock->sock_str:NULL); - bin_push_int(ci->cseq); - bin_push_int(ci->flags); - bin_push_int(ci->cflags); -@@ -142,7 +142,7 @@ void replicate_ucontact_update(urecord_t *r, str *contact, ucontact_info_t *ci) - st.len = sizeof ci->q; - bin_push_str(&st); - -- bin_push_str(&ci->sock->sock_str); -+ bin_push_str(ci->sock?&ci->sock->sock_str:NULL); - bin_push_int(ci->cseq); - bin_push_int(ci->flags); - bin_push_int(ci->cflags); -@@ -289,21 +289,21 @@ static int receive_ucontact_insert(void) - - bin_pop_str(&sock); - -- if (!sock.s || sock.s[0] == 0) { -- LM_ERR("bad received socket: '%.*s'\n", sock.len, sock.s); -- goto error; -- } -+ if (sock.s && sock.s[0]) { -+ if (parse_phostport(sock.s, sock.len, &host.s, &host.len, -+ &port, &proto) != 0) { -+ LM_ERR("bad socket <%.*s>\n", sock.len, sock.s); -+ goto error; -+ } - -- if (parse_phostport(sock.s, sock.len, &host.s, &host.len, -- &port, &proto) != 0) { -- LM_ERR("bad socket <%.*s>\n", sock.len, sock.s); -- goto error; -+ ci.sock = grep_sock_info(&host, (unsigned short) port, -+ (unsigned short) proto); -+ if (!ci.sock) -+ LM_DBG("non-local socket <%.*s>\n", sock.len, sock.s); -+ } else { -+ ci.sock = NULL; - } - -- ci.sock = grep_sock_info(&host, (unsigned short) port, (unsigned short) proto); -- if (!ci.sock) -- LM_DBG("non-local socket <%.*s>\n", sock.len, sock.s); -- - bin_pop_int(&ci.cseq); - bin_pop_int(&ci.flags); - bin_pop_int(&ci.cflags); -@@ -388,21 +388,21 @@ static int receive_ucontact_update(void) - - bin_pop_str(&sock); - -- if (!sock.s || sock.s[0] == 0) { -- LM_ERR("bad received socket: '%.*s'\n", sock.len, sock.s); -- goto error; -- } -+ if (sock.s && sock.s[0]) { -+ if (parse_phostport(sock.s, sock.len, &host.s, &host.len, -+ &port, &proto) != 0) { -+ LM_ERR("bad socket <%.*s>\n", sock.len, sock.s); -+ goto error; -+ } - -- if (parse_phostport(sock.s, sock.len, &host.s, &host.len, -- &port, &proto) != 0) { -- LM_ERR("bad socket <%.*s>\n", sock.len, sock.s); -- goto error; -+ ci.sock = grep_sock_info(&host, (unsigned short) port, -+ (unsigned short) proto); -+ if (!ci.sock) -+ LM_DBG("non-local socket <%.*s>\n", sock.len, sock.s); -+ } else { -+ ci.sock = NULL; - } - -- ci.sock = grep_sock_info(&host, (unsigned short) port, (unsigned short) proto); -- if (!ci.sock) -- LM_DBG("non-local socket <%.*s>\n", sock.len, sock.s); -- - bin_pop_int(&ci.cseq); - bin_pop_int(&ci.flags); - bin_pop_int(&ci.cflags); diff --git a/opensips-0017-sms-increase-pin-buffer-to-avoid-warnings.patch b/opensips-0017-sms-increase-pin-buffer-to-avoid-warnings.patch new file mode 100644 index 0000000..25965a2 --- /dev/null +++ b/opensips-0017-sms-increase-pin-buffer-to-avoid-warnings.patch @@ -0,0 +1,18 @@ +From: Razvan Crainea +Date: Fri, 27 Oct 2017 12:05:58 +0300 +Subject: [PATCH] sms: increase pin buffer to avoid warnings + + +diff --git a/modules/sms/libsms_modem.c b/modules/sms/libsms_modem.c +index 2ed7dd8ee..a69b13625 100644 +--- a/modules/sms/libsms_modem.c ++++ b/modules/sms/libsms_modem.c +@@ -212,7 +212,7 @@ int setmodemparams( struct modem *mdm ) + + int initmodem(struct modem *mdm, cds_report cds_report_f) + { +- char command[100]; ++ char command[11 /* "AT+CPIN=""\r" */ + MAX_CHAR_BUF /* pin */ + 1 /* '\0' */]; + char answer[100]; + int retries=0; + int success=0; diff --git a/opensips-0018-b2b_entities-fix-b2b-key-memory-leak.patch b/opensips-0018-b2b_entities-fix-b2b-key-memory-leak.patch deleted file mode 100644 index dde9c3d..0000000 --- a/opensips-0018-b2b_entities-fix-b2b-key-memory-leak.patch +++ /dev/null @@ -1,49 +0,0 @@ -From: Razvan Crainea -Date: Mon, 24 Jul 2017 17:06:25 +0300 -Subject: [PATCH] b2b_entities: fix b2b key memory leak - -(cherry picked from commit 8ba6567f2d81d9a912a6ab9dd0d23d265c77ba41) - -diff --git a/modules/b2b_entities/dlg.c b/modules/b2b_entities/dlg.c -index 3dc941624..36ebe2a48 100644 ---- a/modules/b2b_entities/dlg.c -+++ b/modules/b2b_entities/dlg.c -@@ -1530,19 +1530,22 @@ void free_tm_dlg(dlg_t* td) - int b2b_send_indlg_req(b2b_dlg_t* dlg, enum b2b_entity_type et, - str* b2b_key, str* method, str* ehdr, str* body, unsigned int no_cb) - { -- str* b2b_key_shm; -+ str* b2b_key_shm = NULL; - dlg_t* td = NULL; - transaction_cb* tm_cback; - build_dlg_f build_dlg; - int method_value = dlg->last_method; - int result; - -- b2b_key_shm= b2b_key_copy_shm(b2b_key); -- if(b2b_key_shm== NULL) -- { -- LM_ERR("no more shared memory\n"); -- return -1; -+ if (!no_cb) { -+ b2b_key_shm= b2b_key_copy_shm(b2b_key); -+ if(b2b_key_shm== NULL) -+ { -+ LM_ERR("no more shared memory\n"); -+ return -1; -+ } - } -+ - if(et == B2B_SERVER) - { - build_dlg = b2b_server_build_dlg; -@@ -1560,7 +1563,8 @@ int b2b_send_indlg_req(b2b_dlg_t* dlg, enum b2b_entity_type et, - { - LM_ERR("Failed to build tm dialog structure, was asked to send [%.*s]" - " request\n", method->len, method->s); -- shm_free(b2b_key_shm); -+ if (b2b_key_shm) -+ shm_free(b2b_key_shm); - return -1; - } - diff --git a/opensips-0018-pvar-fix-hdr-to-allow-variable-headers.patch b/opensips-0018-pvar-fix-hdr-to-allow-variable-headers.patch new file mode 100644 index 0000000..f44dfc4 --- /dev/null +++ b/opensips-0018-pvar-fix-hdr-to-allow-variable-headers.patch @@ -0,0 +1,110 @@ +From: Razvan Crainea +Date: Wed, 31 Jan 2018 11:27:07 +0200 +Subject: [PATCH] pvar: fix $hdr() to allow variable headers + +(cherry picked from commit b7862ccdd5290ebd8d41e2f5b0aadc6e93f1e8dd) + +diff --git a/pvar.c b/pvar.c +index 4dd0ee543..8dad234b9 100644 +--- a/pvar.c ++++ b/pvar.c +@@ -2116,6 +2116,38 @@ static int pv_get_avp(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) + } + + ++static int pv_resolve_hdr_name(str *in, pv_value_t *tv) ++{ ++ struct hdr_field hdr; ++ str s; ++ if(in->len>=PV_LOCAL_BUF_SIZE-1) ++ { ++ LM_ERR("name too long\n"); ++ return -1; ++ } ++ memcpy(pv_local_buf, in->s, in->len); ++ pv_local_buf[in->len] = ':'; ++ s.s = pv_local_buf; ++ s.len = in->len+1; ++ ++ if (parse_hname2(s.s, s.s + ((s.len<4)?4:s.len), &hdr)==0) ++ { ++ LM_ERR("error parsing header name [%.*s]\n", s.len, s.s); ++ return -1; ++ } ++ if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T) ++ { ++ LM_DBG("using hdr type (%d) instead of <%.*s>\n", ++ hdr.type, in->len, in->s); ++ tv->flags = 0; ++ tv->ri = hdr.type; ++ } else { ++ tv->flags = PV_VAL_STR; ++ tv->rs = *in; ++ } ++ return 0; ++} ++ + static int pv_get_hdr_prolog(struct sip_msg *msg, pv_param_t *param, pv_value_t *res, pv_value_t* tv) + { + if(msg==NULL || res==NULL || param==NULL) +@@ -2129,6 +2161,8 @@ static int pv_get_hdr_prolog(struct sip_msg *msg, pv_param_t *param, pv_value_t + LM_ERR("invalid name\n"); + return -1; + } ++ if (pv_resolve_hdr_name(&tv->rs, tv) < 0) ++ return -1; + } else { + if(param->pvn.u.isname.type == AVP_NAME_STR) + { +@@ -2985,10 +3019,9 @@ int pv_parse_scriptvar_name(pv_spec_p sp, str *in) + + int pv_parse_hdr_name(pv_spec_p sp, str *in) + { +- str s; + char *p; + pv_spec_p nsp = 0; +- struct hdr_field hdr; ++ pv_value_t tv; + + if(in==NULL || in->s==NULL || sp==NULL) + return -1; +@@ -3016,35 +3049,21 @@ int pv_parse_hdr_name(pv_spec_p sp, str *in) + return 0; + } + +- if(in->len>=PV_LOCAL_BUF_SIZE-1) +- { +- LM_ERR("name too long\n"); ++ if (pv_resolve_hdr_name(in, &tv) < 0) + return -1; +- } +- memcpy(pv_local_buf, in->s, in->len); +- pv_local_buf[in->len] = ':'; +- s.s = pv_local_buf; +- s.len = in->len+1; + +- if (parse_hname2(s.s, s.s + ((s.len<4)?4:s.len), &hdr)==0) +- { +- LM_ERR("error parsing header name [%.*s]\n", s.len, s.s); +- goto error; +- } + sp->pvp.pvn.type = PV_NAME_INTSTR; +- if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T) ++ if (!tv.flags) + { + LM_DBG("using hdr type (%d) instead of <%.*s>\n", +- hdr.type, in->len, in->s); ++ tv.ri, in->len, in->s); + sp->pvp.pvn.u.isname.type = 0; +- sp->pvp.pvn.u.isname.name.n = hdr.type; ++ sp->pvp.pvn.u.isname.name.n = tv.ri; + } else { + sp->pvp.pvn.u.isname.type = AVP_NAME_STR; + sp->pvp.pvn.u.isname.name.s = *in; + } + return 0; +-error: +- return -1; + } + + int pv_parse_avp_name(pv_spec_p sp, str *in) diff --git a/opensips-0019-Fixed-wrong-TLS-parameters.patch b/opensips-0019-Fixed-wrong-TLS-parameters.patch deleted file mode 100644 index f8da89f..0000000 --- a/opensips-0019-Fixed-wrong-TLS-parameters.patch +++ /dev/null @@ -1,81 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Tue, 25 Jul 2017 14:18:08 +0300 -Subject: [PATCH] Fixed wrong TLS parameters. - -TLS configuration parameters were moved from proto_tls to tls_mgm module. -Credits to Mike Tesliuk for reporting this. - -(cherry picked from commit f0e36896be10c69581ebf77def209df084c82d13) - -diff --git a/menuconfig/configs/opensips_loadbalancer.m4 b/menuconfig/configs/opensips_loadbalancer.m4 -index fcd468394..98506c3f1 100644 ---- a/menuconfig/configs/opensips_loadbalancer.m4 -+++ b/menuconfig/configs/opensips_loadbalancer.m4 -@@ -145,12 +145,13 @@ loadmodule "proto_udp.so" - - ifelse(ENABLE_TCP, `yes', `loadmodule "proto_tcp.so"' , `') - ifelse(ENABLE_TLS, `yes', `loadmodule "proto_tls.so" --modparam("proto_tls","verify_cert", "1") --modparam("proto_tls","require_cert", "0") --modparam("proto_tls","tls_method", "TLSv1") --modparam("proto_tls","certificate", "/usr/local/etc/opensips/tls/user/user-cert.pem") --modparam("proto_tls","private_key", "/usr/local/etc/opensips/tls/user/user-privkey.pem") --modparam("proto_tls","ca_list", "/usr/local/etc/opensips/tls/user/user-calist.pem") -+loadmodule "tls_mgm.so" -+modparam("tls_mgm","verify_cert", "1") -+modparam("tls_mgm","require_cert", "0") -+modparam("tls_mgm","tls_method", "TLSv1") -+modparam("tls_mgm","certificate", "/usr/local/etc/opensips/tls/user/user-cert.pem") -+modparam("tls_mgm","private_key", "/usr/local/etc/opensips/tls/user/user-privkey.pem") -+modparam("tls_mgm","ca_list", "/usr/local/etc/opensips/tls/user/user-calist.pem") - - ' , `') - -diff --git a/menuconfig/configs/opensips_residential.m4 b/menuconfig/configs/opensips_residential.m4 -index 94b9d6cc3..7018fa326 100644 ---- a/menuconfig/configs/opensips_residential.m4 -+++ b/menuconfig/configs/opensips_residential.m4 -@@ -197,12 +197,13 @@ loadmodule "proto_udp.so" - - ifelse(ENABLE_TCP, `yes', `loadmodule "proto_tcp.so"' , `') - ifelse(ENABLE_TLS, `yes', `loadmodule "proto_tls.so" --modparam("proto_tls","verify_cert", "1") --modparam("proto_tls","require_cert", "0") --modparam("proto_tls","tls_method", "TLSv1") --modparam("proto_tls","certificate", "/usr/local/etc/opensips/tls/user/user-cert.pem") --modparam("proto_tls","private_key", "/usr/local/etc/opensips/tls/user/user-privkey.pem") --modparam("proto_tls","ca_list", "/usr/local/etc/opensips/tls/user/user-calist.pem") -+loadmodule "tls_mgm.so" -+modparam("tls_mgm","verify_cert", "1") -+modparam("tls_mgm","require_cert", "0") -+modparam("tls_mgm","tls_method", "TLSv1") -+modparam("tls_mgm","certificate", "/usr/local/etc/opensips/tls/user/user-cert.pem") -+modparam("tls_mgm","private_key", "/usr/local/etc/opensips/tls/user/user-privkey.pem") -+modparam("tls_mgm","ca_list", "/usr/local/etc/opensips/tls/user/user-calist.pem") - - ' , `') - -diff --git a/menuconfig/configs/opensips_trunking.m4 b/menuconfig/configs/opensips_trunking.m4 -index 9b9500c05..6d2df2fac 100644 ---- a/menuconfig/configs/opensips_trunking.m4 -+++ b/menuconfig/configs/opensips_trunking.m4 -@@ -141,12 +141,13 @@ loadmodule "proto_udp.so" - - ifelse(ENABLE_TCP, `yes', `loadmodule "proto_tcp.so"' , `') - ifelse(ENABLE_TLS, `yes', `loadmodule "proto_tls.so" --modparam("proto_tls","verify_cert", "1") --modparam("proto_tls","require_cert", "0") --modparam("proto_tls","tls_method", "TLSv1") --modparam("proto_tls","certificate", "/usr/local/etc/opensips/tls/user/user-cert.pem") --modparam("proto_tls","private_key", "/usr/local/etc/opensips/tls/user/user-privkey.pem") --modparam("proto_tls","ca_list", "/usr/local/etc/opensips/tls/user/user-calist.pem") -+loadmodule "tls_mgm.so" -+modparam("tls_mgm","verify_cert", "1") -+modparam("tls_mgm","require_cert", "0") -+modparam("tls_mgm","tls_method", "TLSv1") -+modparam("tls_mgm","certificate", "/usr/local/etc/opensips/tls/user/user-cert.pem") -+modparam("tls_mgm","private_key", "/usr/local/etc/opensips/tls/user/user-privkey.pem") -+modparam("tls_mgm","ca_list", "/usr/local/etc/opensips/tls/user/user-calist.pem") - - ' , `') - diff --git a/opensips-0019-ratelimit-replicate-the-current-counter-for-SBT.patch b/opensips-0019-ratelimit-replicate-the-current-counter-for-SBT.patch new file mode 100644 index 0000000..29eb23f --- /dev/null +++ b/opensips-0019-ratelimit-replicate-the-current-counter-for-SBT.patch @@ -0,0 +1,24 @@ +From: Razvan Crainea +Date: Thu, 1 Feb 2018 10:59:55 +0200 +Subject: [PATCH] ratelimit: replicate the current counter for SBT + +(cherry picked from commit 08bc17915bc113ee045f8a6d37257450a199c753) + +diff --git a/modules/ratelimit/ratelimit_helper.c b/modules/ratelimit/ratelimit_helper.c +index 65084f81a..104b4a9f4 100644 +--- a/modules/ratelimit/ratelimit_helper.c ++++ b/modules/ratelimit/ratelimit_helper.c +@@ -1056,7 +1056,12 @@ void rl_timer_repl(utime_t ticks, void *param) + if (bin_push_int((*pipe)->limit) < 0) + goto error; + +- if ((ret = bin_push_int((*pipe)->my_last_counter)) < 0) ++ /* ++ * for the SBT algorithm it is safe to replicate the current ++ * counter, since it is always updating according to the window ++ */ ++ if ((ret = bin_push_int(((*pipe)->algo == PIPE_ALGO_HISTORY ? ++ (*pipe)->counter : (*pipe)->my_last_counter))) < 0) + goto error; + nr++; + diff --git a/opensips-0020-cfg-fix-error-reporting-for-unenclosed-scriptvars.patch b/opensips-0020-cfg-fix-error-reporting-for-unenclosed-scriptvars.patch new file mode 100644 index 0000000..f395e4e --- /dev/null +++ b/opensips-0020-cfg-fix-error-reporting-for-unenclosed-scriptvars.patch @@ -0,0 +1,60 @@ +From: Razvan Crainea +Date: Thu, 1 Feb 2018 17:27:00 +0200 +Subject: [PATCH] cfg: fix error reporting for unenclosed scriptvars + +(cherry picked from commit adfc62b55cc2ada7ccac78bdaeab3bbdd47e5abf) + +diff --git a/cfg.lex b/cfg.lex +index 0fb1804a1..1b3e74431 100644 +--- a/cfg.lex ++++ b/cfg.lex +@@ -722,15 +722,15 @@ IMPORTFILE "import_file" + {ANY} { count(); return ANY; } + {SLASH} { count(); return SLASH; } + +-{SCRIPTVAR_START} { count(); np=0; state=SCRIPTVAR_S; ++{SCRIPTVAR_START} { np=0; state=SCRIPTVAR_S; + svar_tlen = yyleng; + yymore(); + BEGIN(SCRIPTVARS); + } +-{LPAREN} { count(); np++; yymore(); svar_tlen = yyleng; } ++{LPAREN} { np++; yymore(); svar_tlen = yyleng; } + {RPAREN} { +- count(); + if(np==0 || np==1) { ++ count(); + if(np==0) + { + addstr(&s_buf, yytext, yyleng-1); +@@ -752,8 +752,8 @@ IMPORTFILE "import_file" + } + } + {WHITESPACE} { +- count(); + if(np==0) { ++ count(); + addstr(&s_buf, yytext, yyleng-1); + unput(yytext[yyleng-1]); + yyleng--; +@@ -768,8 +768,8 @@ IMPORTFILE "import_file" + } + } + {SEMICOLON}|{COMMA}|{ASSIGNOP}|{ARITHOP}|{BITOP}|{LOGOP} { +- count(); + if(np==0) { ++ count(); + addstr(&s_buf, yytext, svar_tlen); + while(yyleng>svar_tlen) { + unput(yytext[yyleng-1]); +@@ -886,6 +886,10 @@ IMPORTFILE "import_file" + LM_CRIT("unexpected EOF:" + "comment line open\n"); + break; ++ case SCRIPTVAR_S: ++ LM_CRIT("unexpected EOF in" ++ " unclosed variable\n"); ++ break; + } + if(oss_pop_yy_state()<0) + return 0; diff --git a/opensips-0020-db_mysql-fix-build-against-MariaDB-10.2.patch b/opensips-0020-db_mysql-fix-build-against-MariaDB-10.2.patch deleted file mode 100644 index b06effd..0000000 --- a/opensips-0020-db_mysql-fix-build-against-MariaDB-10.2.patch +++ /dev/null @@ -1,40 +0,0 @@ -From: Augusto Caringi -Date: Thu, 20 Jul 2017 15:07:16 +0200 -Subject: [PATCH] db_mysql: fix build against MariaDB 10.2 - -Fixes the following build error while building against MariaDB 10.2 -library: - -my_con.c: In function 'db_mysql_connect': -my_con.c:68:10: error: 'MYSQL {aka struct st_mysql}' has no member named -'reconnect' -ptr->con->reconnect = 0; - ^~ - -In this new version of the library the reconnect field was moved to -another struct. Setting it through API seems to be a better approach. - -diff --git a/modules/db_mysql/my_con.c b/modules/db_mysql/my_con.c -index 1f192dfed..cc7109be1 100644 ---- a/modules/db_mysql/my_con.c -+++ b/modules/db_mysql/my_con.c -@@ -30,6 +30,7 @@ - - int db_mysql_connect(struct my_con* ptr) - { -+ my_bool reconnect = 0; - /* if connection already in use, close it first*/ - if (ptr->init) - mysql_close(ptr->con); -@@ -65,7 +66,11 @@ int db_mysql_connect(struct my_con* ptr) - return -1; - } - /* force no auto reconnection */ -+#if MYSQL_VERSION_ID >= 50013 -+ mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &reconnect); -+#else - ptr->con->reconnect = 0; -+#endif - - LM_DBG("connection type is %s\n", mysql_get_host_info(ptr->con)); - LM_DBG("protocol version is %d\n", mysql_get_proto_info(ptr->con)); diff --git a/opensips-0021-event_flatstore-fix-possible-crash-when-subscribing.patch b/opensips-0021-event_flatstore-fix-possible-crash-when-subscribing.patch new file mode 100644 index 0000000..06a42b6 --- /dev/null +++ b/opensips-0021-event_flatstore-fix-possible-crash-when-subscribing.patch @@ -0,0 +1,18 @@ +From: Vlad Patrascu +Date: Fri, 2 Feb 2018 16:36:48 +0200 +Subject: [PATCH] event_flatstore: fix possible crash when subscribing + +(cherry picked from commit c4d113a927890bc09b00e5263f44329c4d71099a) + +diff --git a/modules/event_flatstore/event_flatstore.c b/modules/event_flatstore/event_flatstore.c +index 0ad2a2879..3ca3a7964 100644 +--- a/modules/event_flatstore/event_flatstore.c ++++ b/modules/event_flatstore/event_flatstore.c +@@ -164,6 +164,7 @@ static int mod_init(void) { + } + + list_deleted_files = (struct flat_deleted**)(list_files + 1); ++ *list_deleted_files = NULL; + + global_lock = lock_alloc(); + diff --git a/opensips-0021-event_xmlrpc-rebuild-buffer-for-each-event.patch b/opensips-0021-event_xmlrpc-rebuild-buffer-for-each-event.patch deleted file mode 100644 index e97ace4..0000000 --- a/opensips-0021-event_xmlrpc-rebuild-buffer-for-each-event.patch +++ /dev/null @@ -1,33 +0,0 @@ -From: Razvan Crainea -Date: Wed, 16 Aug 2017 11:25:47 +0300 -Subject: [PATCH] event_xmlrpc: rebuild buffer for each event - -This prenvets crashes when multiple xmlrpc subscribers are used - -(cherry picked from commit 1885c0d4679f4b7b62b00512aa9b23de8880bff4) - -diff --git a/modules/event_xmlrpc/xmlrpc_send.c b/modules/event_xmlrpc/xmlrpc_send.c -index ca3413cf8..ab1a2601e 100644 ---- a/modules/event_xmlrpc/xmlrpc_send.c -+++ b/modules/event_xmlrpc/xmlrpc_send.c -@@ -374,11 +374,6 @@ int xmlrpc_build_buffer(str *event_name, evi_reply_sock *sock, - char *b, *p; - evi_param_p param; - -- if (params && (params->flags & XMLRPC_FLAG)) { -- LM_DBG("buffer already built\n"); -- return 0; -- } -- - b_len = XMLRPC_DEFAULT_BUFFER_SIZE; - b = xmlrpc_body_buf; - -@@ -473,8 +468,6 @@ int xmlrpc_build_buffer(str *event_name, evi_reply_sock *sock, - LM_ERR("cannot build send msg\n"); - return -1; - } -- if (params) -- params->flags |= XMLRPC_FLAG; - - return 0; - } diff --git a/opensips-0022-dialog-do-not-allow-callbacks-in-state-DELETED.patch b/opensips-0022-dialog-do-not-allow-callbacks-in-state-DELETED.patch deleted file mode 100644 index b0ea17a..0000000 --- a/opensips-0022-dialog-do-not-allow-callbacks-in-state-DELETED.patch +++ /dev/null @@ -1,27 +0,0 @@ -From: Razvan Crainea -Date: Tue, 29 Aug 2017 12:29:13 +0300 -Subject: [PATCH] dialog: do not allow callbacks in state DELETED - -If these callbacks would have been registered, they will be never ran, -but the free function will still be called. This breaks some modules -(such as acc), which rely the function will be called. - -(cherry picked from commit 83669d2caec38823ce79ccd12eec4ed013e2d867) - -diff --git a/modules/dialog/dlg_cb.c b/modules/dialog/dlg_cb.c -index 3d7327c79..d1cca0264 100644 ---- a/modules/dialog/dlg_cb.c -+++ b/modules/dialog/dlg_cb.c -@@ -127,6 +127,12 @@ int register_dlgcb(struct dlg_cell *dlg, int types, dialog_cb f, - return -1; - } - } -+ /* XXX: do not register callbacks in DELETED state */ -+ if (dlg && dlg->state == DLG_STATE_DELETED) { -+ LM_WARN("Cannot register callbacks in DELETED state (type %x)!\n", types); -+ return -1; -+ } -+ - cb = (struct dlg_callback*)shm_malloc(sizeof(struct dlg_callback)); - if (cb==0) { - LM_ERR("no more shm mem\n"); diff --git a/opensips-0022-event_flatstore-fix-some-locking-issues.patch b/opensips-0022-event_flatstore-fix-some-locking-issues.patch new file mode 100644 index 0000000..2cdd6bd --- /dev/null +++ b/opensips-0022-event_flatstore-fix-some-locking-issues.patch @@ -0,0 +1,217 @@ +From: Vlad Patrascu +Date: Fri, 2 Feb 2018 17:49:53 +0200 +Subject: [PATCH] event_flatstore: fix some locking issues + +(cherry picked from commit e340e70cfaf0762e81b94b896144cb636398022e) + +diff --git a/modules/event_flatstore/event_flatstore.c b/modules/event_flatstore/event_flatstore.c +index 3ca3a7964..a1272c442 100644 +--- a/modules/event_flatstore/event_flatstore.c ++++ b/modules/event_flatstore/event_flatstore.c +@@ -302,55 +302,50 @@ static int insert_in_list(struct flat_socket *entry) { + struct flat_socket *head = *list_files, *aux, *parent = NULL; + int expected = initial_capacity - 1; + +- lock_get(global_lock); +- + if (head == NULL) { + LM_DBG("Its the single entry in list [%s]\n", entry->path.s); + entry->file_index_process = 0; + *list_files = entry; + entry->prev = NULL; + entry->next = NULL; +- lock_release(global_lock); + return 0; + } + + if (head->file_index_process < initial_capacity - 1) { +- LM_DBG("Inserting [%s] at the head of the list, index: [%d]\n",entry->path.s, head->file_index_process + 1); ++ LM_DBG("Inserting [%s] at the head of the list, index: [%d]\n", ++ entry->path.s, head->file_index_process + 1); + entry->file_index_process = head->file_index_process + 1; + entry->prev = NULL; + entry->next = head; + head->prev = entry; + *list_files = entry; +- lock_release(global_lock); + return 0; + } + + for (aux = head; aux != NULL; aux = aux->next, expected--) { + if(aux->file_index_process != expected){ +- LM_DBG("Inserting [%s] in a gap, index: [%d]\n", entry->path.s, expected); ++ LM_DBG("Inserting [%s] in a gap, index: [%d]\n", ++ entry->path.s, expected); + entry->file_index_process = expected; + entry->prev = aux->prev; + entry->next = aux; + aux->prev =entry; + entry->prev->next = entry; +- lock_release(global_lock); + return 0; + } + parent = aux; + } + + if (expected >= 0) { +- LM_DBG("Inserting [%s] at end of list, index: [%d]\n", entry->path.s, expected); ++ LM_DBG("Inserting [%s] at end of list, index: [%d]\n", ++ entry->path.s, expected); + entry->file_index_process = expected; + entry->prev = parent; + entry->next = NULL; + parent->next = entry; +- lock_release(global_lock); + return 0; + } + +- lock_release(global_lock); +- + LM_ERR("no more free sockets\n"); + return -1; + } +@@ -368,23 +363,31 @@ static evi_reply_sock* flat_parse(str socket){ + return NULL; + } + ++ lock_get(global_lock); ++ + /* if not all processes finished closing the file + find the structure and reuse it */ + if (head) { + if (str_cmp(socket, head->socket->path)) { +- LM_DBG("Found structure at head of deleted list, reusing it [%s]\n", head->socket->path.s); ++ LM_DBG("Found structure at head of deleted list, reusing it [%s]\n", ++ head->socket->path.s); + *list_deleted_files = head->next; + entry = head->socket; + shm_free(head); ++ ++ lock_release(global_lock); + return (evi_reply_sock *)((char*)(entry + 1) + socket.len + 1); + } else { + for (aux = head; aux->next != NULL; aux=aux->next) + if (str_cmp(socket, aux->next->socket->path)) { +- LM_DBG("Found structure inside deleted list, reusing it [%s]\n", aux->next->socket->path.s); ++ LM_DBG("Found structure inside deleted list, reusing it [%s]\n", ++ aux->next->socket->path.s); + tmp = aux->next; + aux->next = aux->next->next; + entry = tmp->socket; + shm_free(tmp); ++ ++ lock_release(global_lock); + return (evi_reply_sock *)((char*)(entry + 1) + socket.len + 1); + } + } +@@ -394,6 +397,7 @@ static evi_reply_sock* flat_parse(str socket){ + + if (!entry) { + LM_ERR("not enough shared memory\n"); ++ lock_release(global_lock); + return NULL; + } + +@@ -416,6 +420,7 @@ static evi_reply_sock* flat_parse(str socket){ + if (stat(dname, &st_buf) < 0) { + LM_ERR("invalid directory name\n"); + shm_free(entry); ++ lock_release(global_lock); + return NULL; + } + +@@ -424,11 +429,13 @@ static evi_reply_sock* flat_parse(str socket){ + if (stat(entry->path.s, &st_buf) == 0 && S_ISDIR (st_buf.st_mode)) { + LM_ERR("path is a directory\n"); + shm_free(entry); ++ lock_release(global_lock); + return NULL; + } + + if (insert_in_list(entry) < 0) { + shm_free(entry); ++ lock_release(global_lock); + return NULL; + } + +@@ -445,6 +452,8 @@ static evi_reply_sock* flat_parse(str socket){ + sock->flags |= EVI_ADDRESS; + sock->flags |= EVI_EXPIRE; + ++ lock_release(global_lock); ++ + return sock; + } + +@@ -457,6 +466,9 @@ static void rotating(struct flat_socket *fs){ + + lock_get(global_lock); + ++ if (!fs) ++ return; ++ + if (opened_fds[index] == -1) { + opened_fds[index] = open(fs->path.s,O_RDWR | O_APPEND | O_CREAT, file_permissions_oct); + if (opened_fds[index] < 0) { +@@ -505,9 +517,9 @@ static int flat_raise(struct sip_msg *msg, str* ev_name, + char endline = '\n'; + char *ptr_buff; + int nr_params = 0; ++ int f_idx; + +- if (entry) +- rotating(entry); ++ rotating(entry); + + verify_delete(); + +@@ -569,8 +581,12 @@ static int flat_raise(struct sip_msg *msg, str* ev_name, + io_param[idx].iov_len = 1; + idx++; + ++ lock_get(global_lock); ++ f_idx = entry->file_index_process; ++ lock_release(global_lock); ++ + do { +- nwritten = writev(opened_fds[entry->file_index_process], io_param, idx); ++ nwritten = writev(opened_fds[f_idx], io_param, idx); + } while (nwritten < 0 && errno == EINTR); + + if (ev_name && ev_name->s) +@@ -622,17 +638,23 @@ static void verify_delete(void) { + struct flat_deleted *head = *list_deleted_files; + struct flat_deleted *aux, *prev, *tmp; + +- if (head == NULL && opened_fds == NULL) ++ if (opened_fds == NULL) + return; + + lock_get(global_lock); + ++ if (head == NULL) { ++ lock_release(global_lock); ++ return; ++ } ++ + /* close fd if necessary */ + aux = head; + prev = NULL; + while (aux != NULL) { + if (opened_fds[aux->socket->file_index_process] != -1) { +- LM_DBG("File %s is closed locally, open_counter is %d\n", aux->socket->path.s, aux->socket->counter_open - 1); ++ LM_DBG("File %s is closed locally, open_counter is %d\n", ++ aux->socket->path.s, aux->socket->counter_open - 1); + close(opened_fds[aux->socket->file_index_process]); + aux->socket->counter_open--; + opened_fds[aux->socket->file_index_process] = -1; +@@ -640,7 +662,8 @@ static void verify_delete(void) { + + /* free file from lists if all other processes closed it */ + if (aux->socket->counter_open == 0) { +- LM_DBG("File %s is deleted globally, count open reached 0\n", aux->socket->path.s); ++ LM_DBG("File %s is deleted globally, count open reached 0\n", ++ aux->socket->path.s); + if (aux->socket->prev) + aux->socket->prev->next = aux->socket->next; + else diff --git a/opensips-0023-event_flatstore-return-proper-error-message-for-evi_.patch b/opensips-0023-event_flatstore-return-proper-error-message-for-evi_.patch new file mode 100644 index 0000000..cbadd79 --- /dev/null +++ b/opensips-0023-event_flatstore-return-proper-error-message-for-evi_.patch @@ -0,0 +1,29 @@ +From: Vlad Patrascu +Date: Fri, 2 Feb 2018 17:59:19 +0200 +Subject: [PATCH] event_flatstore: return proper error message for + evi_flat_rotate + +(cherry picked from commit 47aa5f7a464f6c70e803f10e17eb8d841a5dffd3) + +diff --git a/modules/event_flatstore/event_flatstore.c b/modules/event_flatstore/event_flatstore.c +index a1272c442..852bdeafa 100644 +--- a/modules/event_flatstore/event_flatstore.c ++++ b/modules/event_flatstore/event_flatstore.c +@@ -267,12 +267,14 @@ static struct mi_root* mi_rotate(struct mi_root* root, void *param){ + struct flat_socket *found_fd = search_for_fd(root->node.kids->value); + + if (found_fd == NULL) { +- LM_DBG("Not found path %.*s [lung : %d]\n",root->node.kids->value.len, root->node.kids->value.s, root->node.kids->value.len); ++ LM_DBG("Path: %.*s is not valid\n", root->node.kids->value.len, ++ root->node.kids->value.s); + lock_release(global_lock); +- return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM));; ++ return init_mi_tree( 400, MI_SSTR("File not found")); + } + +- LM_DBG("Found file descriptor and updating rotating version for %s, to %d\n",found_fd->path.s, found_fd->rotate_version + 1); ++ LM_DBG("Found file descriptor and updating rotating version for %s, to %d\n", ++ found_fd->path.s, found_fd->rotate_version + 1); + + found_fd->rotate_version++; + diff --git a/opensips-0023-ratelimit-fix-buffer-overflow-when-using-SBT-algorit.patch b/opensips-0023-ratelimit-fix-buffer-overflow-when-using-SBT-algorit.patch deleted file mode 100644 index 36ebdc0..0000000 --- a/opensips-0023-ratelimit-fix-buffer-overflow-when-using-SBT-algorit.patch +++ /dev/null @@ -1,24 +0,0 @@ -From: Razvan Crainea -Date: Thu, 31 Aug 2017 15:40:02 +0300 -Subject: [PATCH] ratelimit: fix buffer overflow when using SBT algorithm - -Make sure the window doesn't overflow -Fixes #1176 - -(cherry picked from commit d8854637e9329e7d6a52b87aa5cc4601450011c3) - -diff --git a/modules/ratelimit/ratelimit.c b/modules/ratelimit/ratelimit.c -index cb77a5438..2cfb9c686 100644 ---- a/modules/ratelimit/ratelimit.c -+++ b/modules/ratelimit/ratelimit.c -@@ -555,8 +555,8 @@ static inline int hist_check(rl_pipe_t *pipe) - pipe->rwin.start_index = first_good_index; - - /* count current call; it will be the last element in the window */ -- pipe->rwin.window[(pipe->rwin.start_index) -- + (pipe->rwin.window_size-1) % pipe->rwin.window_size]++; -+ pipe->rwin.window[((pipe->rwin.start_index) -+ + (pipe->rwin.window_size-1)) % pipe->rwin.window_size]++; - - } else { /* now_total - start_total < rl_win_ms */ - /* no need to modify the window, the value is inside it; diff --git a/opensips-0024-Fix-reverse_hex2int-prototype.patch b/opensips-0024-Fix-reverse_hex2int-prototype.patch new file mode 100644 index 0000000..15f4217 --- /dev/null +++ b/opensips-0024-Fix-reverse_hex2int-prototype.patch @@ -0,0 +1,189 @@ +From: Bogdan-Andrei Iancu +Date: Tue, 30 Jan 2018 14:07:42 +0200 +Subject: [PATCH] Fix reverse_hex2int() prototype + +As the computed value is an unsigned (as data size), it cannot be returned as int as it will overflow and get converted to a negative value. This will colide with the negative error ret code -1 +Reported by Daniel Zanutti. + +(cherry picked from commit 095dc57300b9665b090e999a540db8b391f8d22e) + +diff --git a/forward.c b/forward.c +index f0af2c079..835e8b4eb 100644 +--- a/forward.c ++++ b/forward.c +@@ -468,7 +468,7 @@ int forward_reply(struct sip_msg* msg) + unsigned int new_len; + struct sr_module *mod; + int proto; +- int id; /* used only by tcp*/ ++ unsigned int id; /* used only by tcp*/ + struct socket_info *send_sock; + char* s; + int len; +@@ -523,7 +523,7 @@ int forward_reply(struct sip_msg* msg) + if (msg->via1->i&&msg->via1->i->value.s){ + s=msg->via1->i->value.s; + len=msg->via1->i->value.len; +- id=reverse_hex2int(s, len); ++ reverse_hex2int(s, len, &id); + } + } + +@@ -535,7 +535,7 @@ int forward_reply(struct sip_msg* msg) + goto error; + } + +- if (msg_send(send_sock, proto, to, id, new_buf, new_len, msg)<0) { ++ if (msg_send(send_sock, proto, to, (int)id, new_buf, new_len, msg)<0) { + update_stat( drp_rpls, 1); + goto error0; + } +diff --git a/modules/dialog/dlg_handlers.c b/modules/dialog/dlg_handlers.c +index dccafe63f..745f2a95e 100644 +--- a/modules/dialog/dlg_handlers.c ++++ b/modules/dialog/dlg_handlers.c +@@ -1386,8 +1386,8 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param) + str callid; + str ftag; + str ttag; +- int h_entry; +- int h_id; ++ unsigned int h_entry; ++ unsigned int h_id; + int new_state; + int old_state; + int unref; +diff --git a/modules/dialog/dlg_handlers.h b/modules/dialog/dlg_handlers.h +index 2b0471468..9f7f634c3 100644 +--- a/modules/dialog/dlg_handlers.h ++++ b/modules/dialog/dlg_handlers.h +@@ -107,7 +107,7 @@ typedef int (*terminate_dlg_f)(unsigned int h_entry, unsigned int h_id,str *reas + void unreference_dialog(void *dialog); + + static inline int parse_dlg_rr_param(char *p, char *end, +- int *h_entry, int *h_id) ++ unsigned int *h_entry, unsigned int *h_id) + { + char *s; + +@@ -117,12 +117,12 @@ static inline int parse_dlg_rr_param(char *p, char *end, + return -1; + } + +- if ( (*h_entry=reverse_hex2int( s, p-s))<0 ) { ++ if ( reverse_hex2int( s, p-s, h_entry)<0 ) { + LM_ERR("invalid hash entry '%.*s'\n", (int)(long)(p-s), s); + return -1; + } + +- if ( (*h_id=reverse_hex2int( p+1, end-(p+1)))<0 ) { ++ if ( reverse_hex2int( p+1, end-(p+1), h_id)<0 ) { + LM_ERR("invalid hash id '%.*s'\n", (int)(long)(end-(p+1)), p+1 ); + return -1; + } +diff --git a/modules/nathelper/sip_pinger.h b/modules/nathelper/sip_pinger.h +index bd74358ba..ceee556fd 100644 +--- a/modules/nathelper/sip_pinger.h ++++ b/modules/nathelper/sip_pinger.h +@@ -94,7 +94,8 @@ static void init_sip_ping(int rto) + + static int parse_branch(str branch) + { +- int hash_id, cid_len; ++ unsigned int hash_id; ++ int cid_len; + char *end; + + int64_t ret; +@@ -115,13 +116,13 @@ static int parse_branch(str branch) + if (0 == end) { + /* if reverse hex2int succeeds on this it's a simple + * ping based on sipping_callid_cnt label */ +- if (reverse_hex2int(branch.s, end-branch.s) > 0) ++ if (reverse_hex2int(branch.s, end-branch.s, &hash_id)==0) + return 0; + + return 1; + } + +- hash_id = reverse_hex2int(branch.s, end-branch.s); ++ reverse_hex2int(branch.s, end-branch.s, &hash_id); + + branch.len -= (end-branch.s + 1); + branch.s = end+1; +diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c +index 13ad3f07c..5ea8a76cd 100644 +--- a/modules/tm/t_lookup.c ++++ b/modules/tm/t_lookup.c +@@ -683,9 +683,9 @@ found: + int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) + { + struct cell* p_cell; +- int hash_index = 0; +- int entry_label = 0; +- int branch_id = 0; ++ unsigned int hash_index = 0; ++ unsigned int entry_label = 0; ++ unsigned int branch_id = 0; + char *hashi, *branchi, *p, *n; + int hashl, branchl; + int scan_space; +@@ -754,19 +754,19 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) + branchi=p; + + /* sanity check */ +- if ((hash_index=reverse_hex2int(hashi, hashl))<0 ++ if (reverse_hex2int(hashi, hashl, &hash_index)<0 + ||hash_index>=TM_TABLE_ENTRIES +- || (branch_id=reverse_hex2int(branchi, branchl))<0 ++ || reverse_hex2int(branchi, branchl, &branch_id)<0 + ||branch_id>=MAX_BRANCHES +- || (syn_branch ? (entry_label=reverse_hex2int(syni, synl))<0 ++ || (syn_branch ? reverse_hex2int(syni, synl, &entry_label)<0 + : loopl!=MD5_LEN ) + ) { +- LM_DBG("poor reply labels %d label %d branch %d\n", ++ LM_DBG("poor reply labels %u label %u branch %u\n", + hash_index, entry_label, branch_id ); + goto nomatch2; + } + +- LM_DBG("hash %d label %d branch %d\n",hash_index, entry_label, branch_id); ++ LM_DBG("hash %u label %d branch %u\n",hash_index, entry_label, branch_id); + + cseq = get_cseq(p_msg); + +diff --git a/ut.h b/ut.h +index c9c109669..83d12b0ed 100644 +--- a/ut.h ++++ b/ut.h +@@ -238,22 +238,21 @@ static inline char* q_memrchr(char* p, int c, unsigned int size) + } + + +-inline static int reverse_hex2int( char *c, int len ) ++inline static int reverse_hex2int( char *c, int len, unsigned int *r) + { + char *pc; +- int r; + char mychar; + +- r=0; ++ *r=0; + for (pc=c+len-1; len>0; pc--, len--) { +- r <<= 4 ; ++ (*r) <<= 4 ; + mychar=*pc; +- if ( mychar >='0' && mychar <='9') r+=mychar -'0'; +- else if (mychar >='a' && mychar <='f') r+=mychar -'a'+10; +- else if (mychar >='A' && mychar <='F') r+=mychar -'A'+10; ++ if ( mychar >='0' && mychar <='9') (*r)+=mychar -'0'; ++ else if (mychar >='a' && mychar <='f') (*r)+=mychar -'a'+10; ++ else if (mychar >='A' && mychar <='F') (*r)+=mychar -'A'+10; + else return -1; + } +- return r; ++ return 0; + } + + inline static int int2reverse_hex( char **c, int *size, unsigned int nr ) diff --git a/opensips-0024-siptrace-fix-type-for-message-DB-column-value-str-in.patch b/opensips-0024-siptrace-fix-type-for-message-DB-column-value-str-in.patch deleted file mode 100644 index cdee170..0000000 --- a/opensips-0024-siptrace-fix-type-for-message-DB-column-value-str-in.patch +++ /dev/null @@ -1,131 +0,0 @@ -From: rvlad-patrascu -Date: Thu, 31 Aug 2017 15:08:16 +0300 -Subject: [PATCH] siptrace: fix type for message DB column value, str instead - of blob - -(cherry picked from commit 36f43169e238a53f7c077832f4d968ca8be38b4f) - -Conflicts: - modules/siptrace/siptrace.c - -diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c -index f626e5ab9..73b7b3cf9 100644 ---- a/modules/siptrace/siptrace.c -+++ b/modules/siptrace/siptrace.c -@@ -744,7 +744,7 @@ static void init_db_cols(void) - } while(0); - - -- COL_INIT(msg, 0, BLOB); -+ COL_INIT(msg, 0, STR); - COL_INIT(callid, 1, STR); - COL_INIT(method, 2, STR); - COL_INIT(status, 3, STR); -@@ -952,8 +952,8 @@ static int save_siptrace(struct sip_msg *msg, db_key_t *keys, db_val_t *vals, - - break; - case TYPE_SIP: -- if (trace_send_duplicate(db_vals[0].val.blob_val.s, -- db_vals[0].val.blob_val.len, &it->el.uri) < 0) { -+ if (trace_send_duplicate(db_vals[0].val.str_val.s, -+ db_vals[0].val.str_val.len, &it->el.uri) < 0) { - LM_ERR("Faield to duplicate with sip to <%.*s:%.*s>\n", - it->el.uri.host.len, it->el.uri.host.s, - it->el.uri.port.len, it->el.uri.port.s); -@@ -1557,8 +1557,8 @@ static int sip_trace(struct sip_msg *msg, trace_info_p info) - - - LM_DBG("sip_trace called \n"); -- db_vals[0].val.blob_val.s = msg->buf; -- db_vals[0].val.blob_val.len = msg->len; -+ db_vals[0].val.str_val.s = msg->buf; -+ db_vals[0].val.str_val.len = msg->len; - - db_vals[1].val.str_val.s = msg->callid->body.s; - db_vals[1].val.str_val.len = msg->callid->body.len; -@@ -1679,8 +1679,8 @@ static void trace_slreply_out(struct sip_msg* req, str *buffer,int rpl_code, - return; - } - -- db_vals[0].val.blob_val.s = (buffer)?buffer->s:""; -- db_vals[0].val.blob_val.len = (buffer)?buffer->len:0; -+ db_vals[0].val.str_val.s = (buffer)?buffer->s:""; -+ db_vals[0].val.str_val.len = (buffer)?buffer->len:0; - - /* check Call-ID header */ - if(req->callid==NULL || req->callid->body.s==NULL) -@@ -1770,11 +1770,11 @@ static void trace_msg_out(struct sip_msg* msg, str *sbuf, - - if(sbuf!=NULL && sbuf->len>0) - { -- db_vals[0].val.blob_val.s = sbuf->s; -- db_vals[0].val.blob_val.len = sbuf->len; -+ db_vals[0].val.str_val.s = sbuf->s; -+ db_vals[0].val.str_val.len = sbuf->len; - } else { -- db_vals[0].val.blob_val.s = "No request buffer"; -- db_vals[0].val.blob_val.len = sizeof("No request buffer")-1; -+ db_vals[0].val.str_val.s = "No request buffer"; -+ db_vals[0].val.str_val.len = sizeof("No request buffer")-1; - } - - /* check Call-ID header */ -@@ -1886,11 +1886,11 @@ static void trace_onreply_in(struct cell* t, int type, struct tmcb_params *ps) - } - - if(msg->len>0) { -- db_vals[0].val.blob_val.s = msg->buf; -- db_vals[0].val.blob_val.len = msg->len; -+ db_vals[0].val.str_val.s = msg->buf; -+ db_vals[0].val.str_val.len = msg->len; - } else { -- db_vals[0].val.blob_val.s = "No reply buffer"; -- db_vals[0].val.blob_val.len = sizeof("No reply buffer")-1; -+ db_vals[0].val.str_val.s = "No reply buffer"; -+ db_vals[0].val.str_val.len = sizeof("No reply buffer")-1; - } - - /* check Call-ID header */ -@@ -1987,28 +1987,28 @@ static void trace_onreply_out(struct cell* t, int type, struct tmcb_params *ps) - if(faked==0) - { - if(sbuf!=0 && sbuf->len>0) { -- db_vals[0].val.blob_val.s = sbuf->s; -- db_vals[0].val.blob_val.len = sbuf->len; -+ db_vals[0].val.str_val.s = sbuf->s; -+ db_vals[0].val.str_val.len = sbuf->len; - } else if(t->uas.response.buffer.s!=NULL) { -- db_vals[0].val.blob_val.s = t->uas.response.buffer.s; -- db_vals[0].val.blob_val.len = t->uas.response.buffer.len; -+ db_vals[0].val.str_val.s = t->uas.response.buffer.s; -+ db_vals[0].val.str_val.len = t->uas.response.buffer.len; - } else if(msg->len>0) { -- db_vals[0].val.blob_val.s = msg->buf; -- db_vals[0].val.blob_val.len = msg->len; -+ db_vals[0].val.str_val.s = msg->buf; -+ db_vals[0].val.str_val.len = msg->len; - } else { -- db_vals[0].val.blob_val.s = "No reply buffer"; -- db_vals[0].val.blob_val.len = sizeof("No reply buffer")-1; -+ db_vals[0].val.str_val.s = "No reply buffer"; -+ db_vals[0].val.str_val.len = sizeof("No reply buffer")-1; - } - } else { - if(sbuf!=0 && sbuf->len>0) { -- db_vals[0].val.blob_val.s = sbuf->s; -- db_vals[0].val.blob_val.len = sbuf->len; -+ db_vals[0].val.str_val.s = sbuf->s; -+ db_vals[0].val.str_val.len = sbuf->len; - } else if(t->uas.response.buffer.s==NULL) { -- db_vals[0].val.blob_val.s = "No reply buffer"; -- db_vals[0].val.blob_val.len = sizeof("No reply buffer")-1; -+ db_vals[0].val.str_val.s = "No reply buffer"; -+ db_vals[0].val.str_val.len = sizeof("No reply buffer")-1; - } else { -- db_vals[0].val.blob_val.s = t->uas.response.buffer.s; -- db_vals[0].val.blob_val.len = t->uas.response.buffer.len; -+ db_vals[0].val.str_val.s = t->uas.response.buffer.s; -+ db_vals[0].val.str_val.len = t->uas.response.buffer.len; - } - } - diff --git a/opensips-0025-Explicit-reset-of-conn-ID-on-error.patch b/opensips-0025-Explicit-reset-of-conn-ID-on-error.patch new file mode 100644 index 0000000..7f34ffc --- /dev/null +++ b/opensips-0025-Explicit-reset-of-conn-ID-on-error.patch @@ -0,0 +1,22 @@ +From: Bogdan-Andrei Iancu +Date: Tue, 30 Jan 2018 14:42:22 +0200 +Subject: [PATCH] Explicit reset of conn ID on error + +if reverse_hex2int fails, be sure the conn id stays 0. + +(cherry picked from commit a61fa8646e6f865b347b3e725c6362dc15d4e57b) + +diff --git a/forward.c b/forward.c +index 835e8b4eb..24dc2da5f 100644 +--- a/forward.c ++++ b/forward.c +@@ -523,7 +523,8 @@ int forward_reply(struct sip_msg* msg) + if (msg->via1->i&&msg->via1->i->value.s){ + s=msg->via1->i->value.s; + len=msg->via1->i->value.len; +- reverse_hex2int(s, len, &id); ++ if (reverse_hex2int(s, len, &id)<0) ++ id = 0; + } + } + diff --git a/opensips-0025-parse_fline-fix-implicit-cast-sign.patch b/opensips-0025-parse_fline-fix-implicit-cast-sign.patch deleted file mode 100644 index fb826d3..0000000 --- a/opensips-0025-parse_fline-fix-implicit-cast-sign.patch +++ /dev/null @@ -1,19 +0,0 @@ -From: Razvan Crainea -Date: Tue, 12 Sep 2017 11:36:40 +0300 -Subject: [PATCH] parse_fline: fix implicit cast sign - -(cherry picked from commit b0eb928e7241e9c8c2fcfff3e3bb3704fbfddae6) - -diff --git a/parser/parse_fline.c b/parser/parse_fline.c -index a7a202242..20548141b 100644 ---- a/parser/parse_fline.c -+++ b/parser/parse_fline.c -@@ -1275,7 +1275,7 @@ error: - if (prn) { - for (t=0; t +Date: Tue, 30 Jan 2018 15:02:47 +0200 +Subject: [PATCH] Fix reverse_hex2int64() prototype + +As the computed value is an unsigned (as data size), it cannot be returned as int as it will overflow and get converted to a negative value. This will colide with the negative error ret code -1 + +(cherry picked from commit ed12eb97c06a23491c8b831124600361b0b63f2f) + +diff --git a/modules/nathelper/sip_pinger.h b/modules/nathelper/sip_pinger.h +index ceee556fd..94e98d5a8 100644 +--- a/modules/nathelper/sip_pinger.h ++++ b/modules/nathelper/sip_pinger.h +@@ -97,8 +97,6 @@ static int parse_branch(str branch) + unsigned int hash_id; + int cid_len; + char *end; +- +- int64_t ret; + uint64_t contact_id=0; + + struct ping_cell *p_cell; +@@ -133,15 +131,12 @@ static int parse_branch(str branch) + + end = q_memchr(branch.s, '.', branch.len); + cid_len = end-branch.s; +- ret = reverse_hex2int64(branch.s, cid_len, 1/* request unsafe parsing */); +- /* we don't parse the label since we don't need it */ +- +- if (ret == -1) { +- LM_ERR("received invalid contact id\n"); +- return -1; +- } ++ reverse_hex2int64(branch.s, cid_len, 1/* request unsafe parsing */, ++ &contact_id); ++ /* reverse_hex2int64() cannot fail in unsafe mode and it will return ++ whatever it was able to parse (0 if nothing )*/ + +- contact_id = (uint64_t)ret; ++ /* we don't parse the label since we don't need it */ + + lock_hash(hash_id); + if ((p_cell=get_cell(hash_id, contact_id))==NULL) { +diff --git a/ut.h b/ut.h +index 83d12b0ed..44c358f54 100644 +--- a/ut.h ++++ b/ut.h +@@ -280,24 +280,23 @@ inline static int int2reverse_hex( char **c, int *size, unsigned int nr ) + /* if unsafe requested when first non numerical character shall be + * met the number shall be returned; avoid giving the + * exact len of the number */ +-inline static int64_t reverse_hex2int64( char *c, int len, int unsafe) ++inline static int reverse_hex2int64( char *c, int len, int unsafe, uint64_t *r) + { + char *pc; +- int64_t r; + char mychar; + +- r=0; ++ *r=0; + for (pc=c+len-1; len>0; pc--, len--) { +- r <<= 4 ; ++ (*r) <<= 4 ; + mychar=*pc; +- if ( mychar >='0' && mychar <='9') r+=mychar -'0'; +- else if (mychar >='a' && mychar <='f') r+=mychar -'a'+10; +- else if (mychar >='A' && mychar <='F') r+=mychar -'A'+10; ++ if ( mychar >='0' && mychar <='9') (*r)+=mychar -'0'; ++ else if (mychar >='a' && mychar <='f') (*r)+=mychar -'a'+10; ++ else if (mychar >='A' && mychar <='F') (*r)+=mychar -'A'+10; + else if (unsafe) +- return r; ++ return 0; + else return -1; + } +- return r; ++ return 0; + } + + inline static int64_t int64_2reverse_hex( char **c, int *size, uint64_t nr ) diff --git a/opensips-0026-proto_wss-write-all-TLS-chunks-under-a-single-lock.patch b/opensips-0026-proto_wss-write-all-TLS-chunks-under-a-single-lock.patch deleted file mode 100644 index d75118d..0000000 --- a/opensips-0026-proto_wss-write-all-TLS-chunks-under-a-single-lock.patch +++ /dev/null @@ -1,95 +0,0 @@ -From: Razvan Crainea -Date: Tue, 12 Sep 2017 11:10:56 +0300 -Subject: [PATCH] proto_wss: write all TLS chunks under a single lock - -Reported by Eric Tamme from OnSIP - -(cherry picked from commit e113e147c71b2fa4f84bed3621b91d1ed1de38f6) - -diff --git a/modules/proto_tls/proto_tls.c b/modules/proto_tls/proto_tls.c -index 7257fc066..27dfe83b9 100644 ---- a/modules/proto_tls/proto_tls.c -+++ b/modules/proto_tls/proto_tls.c -@@ -110,7 +110,12 @@ static int proto_tls_send(struct socket_info* send_sock, - static int w_tls_blocking_write(struct tcp_connection *c, int fd, const char *buf, - size_t len) - { -- return tls_blocking_write(c, fd, buf, len, &tls_mgm_api); -+ int ret; -+ -+ lock_get(&c->write_lock); -+ ret = tls_blocking_write(c, fd, buf, len, &tls_mgm_api); -+ lock_release(&c->write_lock); -+ return ret; - } - - /* buffer to be used for reading all TCP SIP messages -@@ -343,7 +348,9 @@ static int proto_tls_send(struct socket_info* send_sock, - send_it: - LM_DBG("sending via fd %d...\n",fd); - -+ lock_get(&c->write_lock); - n = tls_blocking_write(c, fd, buf, len, &tls_mgm_api); -+ lock_release(&c->write_lock); - tcp_conn_set_lifetime( c, tcp_con_lifetime); - - LM_DBG("after write: c= %p n=%d fd=%d\n",c, n, fd); -diff --git a/modules/proto_wss/proto_wss.c b/modules/proto_wss/proto_wss.c -index 4c4685a4b..ec3ed2050 100644 ---- a/modules/proto_wss/proto_wss.c -+++ b/modules/proto_wss/proto_wss.c -@@ -451,6 +451,7 @@ static int wss_raw_writev(struct tcp_connection *c, int fd, - #endif - - #ifndef TLS_DONT_WRITE_FRAGMENTS -+ lock_get(&c->write_lock); - for (i = 0; i < iovcnt; i++) { - n = tls_blocking_write(c, fd, iov[i].iov_base, iov[i].iov_len, &tls_mgm_api); - if (n < 0) { -@@ -459,6 +460,7 @@ static int wss_raw_writev(struct tcp_connection *c, int fd, - } - ret += n; - } -+ lock_release(&c->write_lock); - #else - n = 0; - for (i = 0; i < iovcnt; i++) -@@ -473,7 +475,9 @@ static int wss_raw_writev(struct tcp_connection *c, int fd, - memcpy(buf + n, iov[i].iov_base, iov[i].iov_len); - n += iov[i].iov_len; - } -+ lock_get(&c->write_lock); - n = tls_blocking_write(c, fd, buf, n, &tls_mgm_api); -+ lock_release(&c->write_lock); - - #endif /* TLS_DONT_WRITE_FRAGMENTS */ - -diff --git a/modules/tls_mgm/tls_conn_server.h b/modules/tls_mgm/tls_conn_server.h -index 240963271..af6c2b309 100644 ---- a/modules/tls_mgm/tls_conn_server.h -+++ b/modules/tls_mgm/tls_conn_server.h -@@ -422,8 +422,6 @@ static int tls_blocking_write(struct tcp_connection *c, int fd, const char *buf, - goto error; - } - -- lock_get(&c->write_lock); -- - if (tls_update_fd(c, fd) < 0) - goto error; - -@@ -474,7 +472,6 @@ again: - /* - * successful full write - */ -- lock_release(&c->write_lock); - return written; - } - -@@ -516,7 +513,6 @@ poll_loop: - } - - error: -- lock_release(&c->write_lock); - return -1; - } - diff --git a/opensips-0027-proto_wss-release-lock-even-if-write-fails.patch b/opensips-0027-proto_wss-release-lock-even-if-write-fails.patch deleted file mode 100644 index aa5b066..0000000 --- a/opensips-0027-proto_wss-release-lock-even-if-write-fails.patch +++ /dev/null @@ -1,32 +0,0 @@ -From: Razvan Crainea -Date: Wed, 13 Sep 2017 17:45:33 +0300 -Subject: [PATCH] proto_wss: release lock even if write fails - -Detected and fixed by Eric Tamme from OnSIP - -(cherry picked from commit 99af2fc44f0b8216bdbe7320d41adb208144ada0) - -diff --git a/modules/proto_wss/proto_wss.c b/modules/proto_wss/proto_wss.c -index ec3ed2050..83c91b6bc 100644 ---- a/modules/proto_wss/proto_wss.c -+++ b/modules/proto_wss/proto_wss.c -@@ -460,7 +460,6 @@ static int wss_raw_writev(struct tcp_connection *c, int fd, - } - ret += n; - } -- lock_release(&c->write_lock); - #else - n = 0; - for (i = 0; i < iovcnt; i++) -@@ -477,10 +476,9 @@ static int wss_raw_writev(struct tcp_connection *c, int fd, - } - lock_get(&c->write_lock); - n = tls_blocking_write(c, fd, buf, n, &tls_mgm_api); -- lock_release(&c->write_lock); -- - #endif /* TLS_DONT_WRITE_FRAGMENTS */ - - end: -+ lock_release(&c->write_lock); - return ret; - } diff --git a/opensips-0027-rtpproxy-fix-test-condition-for-altering-IP-in-SDP-w.patch b/opensips-0027-rtpproxy-fix-test-condition-for-altering-IP-in-SDP-w.patch new file mode 100644 index 0000000..6815af4 --- /dev/null +++ b/opensips-0027-rtpproxy-fix-test-condition-for-altering-IP-in-SDP-w.patch @@ -0,0 +1,20 @@ +From: Ovidiu Sas +Date: Mon, 5 Feb 2018 10:00:14 -0500 +Subject: [PATCH] rtpproxy: fix test condition for altering IP in SDP while + forcing RTP + +(cherry picked from commit 55e9479b32c2d01a12a3278afb75b0fa520605c4) + +diff --git a/modules/rtpproxy/rtpproxy.c b/modules/rtpproxy/rtpproxy.c +index f00e796da..c68ba7251 100644 +--- a/modules/rtpproxy/rtpproxy.c ++++ b/modules/rtpproxy/rtpproxy.c +@@ -1898,7 +1898,7 @@ alter_mediaip(struct sip_msg *msg, str *body, str *oldip, int oldpf, + str omip, nip, oip; + + /* check that updating media-ip is really necessary */ +- if (oldpf == newpf && isnulladdr(oldip, oldpf)) ++ if (oldpf == newpf || isnulladdr(oldip, oldpf)) + return 0; + if (newip->len == oldip->len && + memcmp(newip->s, oldip->s, newip->len) == 0) diff --git a/opensips-0028-Fix-bogus-error-message-probabaly-copy-paste-error.patch b/opensips-0028-Fix-bogus-error-message-probabaly-copy-paste-error.patch deleted file mode 100644 index 022b406..0000000 --- a/opensips-0028-Fix-bogus-error-message-probabaly-copy-paste-error.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Thu, 14 Sep 2017 20:09:36 +0300 -Subject: [PATCH] Fix bogus error message (probabaly copy paste error) - -Credits for the fix go to Michael Mavroudis. - -(cherry picked from commit 9e497ea4ab03c67cb073bdf0dccef2b16bff80e2) - -diff --git a/scripts/opensipsdbctl b/scripts/opensipsdbctl -index fdaa5175c..8bfefa1c4 100755 ---- a/scripts/opensipsdbctl -+++ b/scripts/opensipsdbctl -@@ -126,7 +126,7 @@ case $DBENGINE in - USED_DBENGINE="sqlite" - DBNAME=$DB_PATH - else -- merr "could not load the script in $MYLIBDIR/opensipsdbctl.db_berkeley for database engine $DBENGINE" -+ merr "could not load the script in $MYLIBDIR/opensipsdbctl.sqlite for database engine $DBENGINE" - fi - ;; - diff --git a/opensips-0028-nathelper-manual-backport-for-3c39167e333a8801772f49.patch b/opensips-0028-nathelper-manual-backport-for-3c39167e333a8801772f49.patch new file mode 100644 index 0000000..2c6548a --- /dev/null +++ b/opensips-0028-nathelper-manual-backport-for-3c39167e333a8801772f49.patch @@ -0,0 +1,21 @@ +From: Ovidiu Sas +Date: Mon, 5 Feb 2018 13:03:09 -0500 +Subject: [PATCH] nathelper: manual backport for + 3c39167e333a8801772f49f8561a015bfa1836f1 - fix test condition for updateing + IP for fix_nated_sdp() + +(cherry picked from commit a45d4dcaf046bb273cfe5905ac035845a6867945) + +diff --git a/modules/nathelper/nathelper.c b/modules/nathelper/nathelper.c +index df3e5740b..a919af12d 100644 +--- a/modules/nathelper/nathelper.c ++++ b/modules/nathelper/nathelper.c +@@ -984,7 +984,7 @@ alter_mediaip(struct sip_msg *msg, str *body, str *oldip, int oldpf, + str omip, nip, oip; + + /* check that updating mediaip is really necessary */ +- if (oldpf == newpf && isnulladdr(oldip, oldpf)) ++ if (oldpf == newpf || isnulladdr(oldip, oldpf)) + return 0; + if (newip->len == oldip->len && + memcmp(newip->s, oldip->s, newip->len) == 0) diff --git a/opensips-0029-nathelper-revert-commit-a45d4dcaf046bb273cfe5905ac03.patch b/opensips-0029-nathelper-revert-commit-a45d4dcaf046bb273cfe5905ac03.patch new file mode 100644 index 0000000..25346fe --- /dev/null +++ b/opensips-0029-nathelper-revert-commit-a45d4dcaf046bb273cfe5905ac03.patch @@ -0,0 +1,25 @@ +From: Ovidiu Sas +Date: Mon, 5 Feb 2018 15:32:03 -0500 +Subject: [PATCH] nathelper: revert commit + a45d4dcaf046bb273cfe5905ac035845a6867945 - add comments to better explain + logic behind code + +(cherry picked from commit 1e36fa1afafb90fcffcd88fdecc5c74e24ceb990) + +diff --git a/modules/nathelper/nathelper.c b/modules/nathelper/nathelper.c +index a919af12d..41b7388d8 100644 +--- a/modules/nathelper/nathelper.c ++++ b/modules/nathelper/nathelper.c +@@ -984,7 +984,11 @@ alter_mediaip(struct sip_msg *msg, str *body, str *oldip, int oldpf, + str omip, nip, oip; + + /* check that updating mediaip is really necessary */ +- if (oldpf == newpf || isnulladdr(oldip, oldpf)) ++ /* Conditions: ++ - same IP protocol format for received IP and new IP ++ - null IP received ++ */ ++ if (oldpf == newpf && isnulladdr(oldip, oldpf)) + return 0; + if (newip->len == oldip->len && + memcmp(newip->s, oldip->s, newip->len) == 0) diff --git a/opensips-0029-siptrace-allow-capturing-on-any-port.patch b/opensips-0029-siptrace-allow-capturing-on-any-port.patch deleted file mode 100644 index 1031ff5..0000000 --- a/opensips-0029-siptrace-allow-capturing-on-any-port.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: Razvan Crainea -Date: Fri, 15 Sep 2017 17:13:41 +0300 -Subject: [PATCH] siptrace: allow capturing on any port - -reported by Eric Tamme from OnSIP - -(cherry picked from commit b7f9ca3316f4d6c740fc62599a55bae97026efbd) - -diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c -index 73b7b3cf9..ddc83eda9 100644 ---- a/modules/siptrace/siptrace.c -+++ b/modules/siptrace/siptrace.c -@@ -2377,17 +2377,8 @@ static int pipport2su (str *sproto, str *ip, unsigned short port, - return -1; - } - -- if (port == 0) { -+ if (port == 0) - port = SIP_PORT; -- } -- else{ -- /*the address contains a port number*/ -- if (port<1024 || port>65535) -- { -- LM_ERR("invalid port number; must be in [1024,65536]\n"); -- return -1; -- } -- } - LM_DBG("proto %d, host %.*s , port %d \n",*proto, ip->len, ip->s, port); - - /* now IPv6 address has no brakets. It should be fixed! */ diff --git a/opensips-0030-Merge-pull-request-1191-from-etamme-master.patch b/opensips-0030-Merge-pull-request-1191-from-etamme-master.patch deleted file mode 100644 index 2e6b970..0000000 --- a/opensips-0030-Merge-pull-request-1191-from-etamme-master.patch +++ /dev/null @@ -1,23 +0,0 @@ -From: Bogdan Andrei IANCU -Date: Thu, 21 Sep 2017 12:01:44 +0300 -Subject: [PATCH] Merge pull request #1191 from etamme/master - -fix memory leak in cpl-c write_to_db -(cherry picked from commit 2a64a1455d63fdabf9d9130811d2932e245afd1e) - -diff --git a/modules/cpl_c/cpl_db.c b/modules/cpl_c/cpl_db.c -index 61b510f8a..6e21bd79b 100644 ---- a/modules/cpl_c/cpl_db.c -+++ b/modules/cpl_c/cpl_db.c -@@ -242,8 +242,11 @@ int write_to_db(str *username, str *domain, str *xml, str *bin) - } - } - -+ cpl_dbf.free_result( db_hdl, res); - return 1; - error: -+ if (res) -+ cpl_dbf.free_result( db_hdl, res); - return -1; - } - diff --git a/opensips-0030-rtpproxy-revert-commit-ee2731212303eb7055b3bd165464f.patch b/opensips-0030-rtpproxy-revert-commit-ee2731212303eb7055b3bd165464f.patch new file mode 100644 index 0000000..1a78e83 --- /dev/null +++ b/opensips-0030-rtpproxy-revert-commit-ee2731212303eb7055b3bd165464f.patch @@ -0,0 +1,25 @@ +From: Ovidiu Sas +Date: Mon, 5 Feb 2018 15:58:20 -0500 +Subject: [PATCH] rtpproxy: revert commit + ee2731212303eb7055b3bd165464fe44fae05e7b - add comments to better explain + logic behind code + +(cherry picked from commit ebbe49c50ce045a41b390198e3ee731450aaf600) + +diff --git a/modules/rtpproxy/rtpproxy.c b/modules/rtpproxy/rtpproxy.c +index c68ba7251..945a89111 100644 +--- a/modules/rtpproxy/rtpproxy.c ++++ b/modules/rtpproxy/rtpproxy.c +@@ -1898,7 +1898,11 @@ alter_mediaip(struct sip_msg *msg, str *body, str *oldip, int oldpf, + str omip, nip, oip; + + /* check that updating media-ip is really necessary */ +- if (oldpf == newpf || isnulladdr(oldip, oldpf)) ++ /* Conditions: ++ - same IP protocol format for received IP and new IP ++ - null IP received ++ */ ++ if (oldpf == newpf && isnulladdr(oldip, oldpf)) + return 0; + if (newip->len == oldip->len && + memcmp(newip->s, oldip->s, newip->len) == 0) diff --git a/opensips-0031-Merge-pull-request-1195-from-etamme-master.patch b/opensips-0031-Merge-pull-request-1195-from-etamme-master.patch deleted file mode 100644 index 8967b39..0000000 --- a/opensips-0031-Merge-pull-request-1195-from-etamme-master.patch +++ /dev/null @@ -1,23 +0,0 @@ -From: =?UTF-8?q?R=C4=83zvan=20Crainea?= -Date: Mon, 25 Sep 2017 17:54:29 +0300 -Subject: [PATCH] Merge pull request #1195 from etamme/master - -check if trace id node exists before de-reference (fix segfault) - -(cherry picked from commit 675164c747e4f538dfa34fcdfb46b9adbf3567e4) - -diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c -index ddc83eda9..5553b22fe 100644 ---- a/modules/siptrace/siptrace.c -+++ b/modules/siptrace/siptrace.c -@@ -2192,6 +2192,10 @@ static struct mi_root* sip_trace_mi(struct mi_root* cmd_tree, void* param ) - } - - it=get_list_start(&node->value); -+ if (!it) { -+ return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM)); -+ } -+ - hash=it->hash; - - for (;it&&it->hash==hash;it=it->next) diff --git a/opensips-0031-ratelimit-create-pipe-in-a-generic-manner.patch b/opensips-0031-ratelimit-create-pipe-in-a-generic-manner.patch new file mode 100644 index 0000000..9af1276 --- /dev/null +++ b/opensips-0031-ratelimit-create-pipe-in-a-generic-manner.patch @@ -0,0 +1,120 @@ +From: Razvan Crainea +Date: Wed, 7 Feb 2018 10:32:51 +0200 +Subject: [PATCH] ratelimit: create pipe in a generic manner + +Fix pipe init by merging the pipe create in a single, common function. + +(cherry picked from commit d6933ad99ccfa20edbd375155a4b8e06b4e495a5) +(cherry picked from commit 4b29ec62eff1af6e4a2222d40bfa5cee8c43a64f) + +diff --git a/modules/ratelimit/ratelimit_helper.c b/modules/ratelimit/ratelimit_helper.c +index 104b4a9f4..b6ab6f08d 100644 +--- a/modules/ratelimit/ratelimit_helper.c ++++ b/modules/ratelimit/ratelimit_helper.c +@@ -312,6 +312,35 @@ int w_rl_check_2(struct sip_msg *_m, char *_n, char *_l) + return w_rl_check_3(_m, _n, _l, NULL); + } + ++rl_pipe_t *rl_create_pipe(int limit, rl_algo_t algo) ++{ ++ rl_pipe_t *pipe; ++ int size = sizeof(rl_pipe_t); ++ ++ if (algo == PIPE_ALGO_NOP) ++ algo = rl_default_algo; ++ ++ if (algo == PIPE_ALGO_HISTORY) ++ size += (rl_window_size * 1000) / rl_slot_period * sizeof(long int); ++ ++ pipe = shm_malloc(size); ++ if (!pipe) { ++ LM_ERR("no more shm memory!\n"); ++ return NULL; ++ } ++ memset(pipe, 0, size); ++ ++ pipe->algo = algo; ++ pipe->limit = limit; ++ ++ if (algo == PIPE_ALGO_HISTORY) { ++ pipe->rwin.window = (long int *)(pipe + 1); ++ pipe->rwin.window_size = (rl_window_size * 1000) / rl_slot_period; ++ /* everything else is already cleared */ ++ } ++ return pipe; ++} ++ + int w_rl_check_3(struct sip_msg *_m, char *_n, char *_l, char *_a) + { + str name; +@@ -376,23 +405,13 @@ int w_rl_check_3(struct sip_msg *_m, char *_n, char *_l, char *_a) + + if (!*pipe) { + /* allocate new pipe */ +- *pipe = shm_malloc(sizeof(rl_pipe_t) + +- /* memory for the window */ +- (rl_window_size*1000) / rl_slot_period * sizeof(long int)); +- if (!*pipe) { +- LM_ERR("no more shm memory\n"); ++ if (!(*pipe = rl_create_pipe(limit, algo))) + goto release; +- } +- memset(*pipe, 0, sizeof(rl_pipe_t)); ++ + LM_DBG("Pipe %.*s doesn't exist, but was created %p\n", + name.len, name.s, *pipe); +- if (algo == PIPE_ALGO_NETWORK) ++ if ((*pipe)->algo == PIPE_ALGO_NETWORK) + should_update = 1; +- (*pipe)->algo = (algo == PIPE_ALGO_NOP) ? rl_default_algo : algo; +- (*pipe)->rwin.window = (long int *)((*pipe) + 1); +- (*pipe)->rwin.window_size = rl_window_size * 1000 / rl_slot_period; +- memset((*pipe)->rwin.window, 0, +- (*pipe)->rwin.window_size * sizeof(long int)); + } else { + LM_DBG("Pipe %.*s found: %p - last used %lu\n", + name.len, name.s, *pipe, (*pipe)->last_used); +@@ -400,11 +419,10 @@ int w_rl_check_3(struct sip_msg *_m, char *_n, char *_l, char *_a) + LM_WARN("algorithm %d different from the initial one %d for pipe " + "%.*s", algo, (*pipe)->algo, name.len, name.s); + } ++ /* update the limit */ ++ (*pipe)->limit = limit; + } + +- /* set/update the limit */ +- (*pipe)->limit = limit; +- + /* set the last used time */ + (*pipe)->last_used = time(0); + if (RL_USE_CDB(*pipe)) { +@@ -890,17 +908,12 @@ void rl_rcv_bin(int packet_type, struct receive_info *ri, int server_id) + } + + if (!*pipe) { +- /* if the pipe does not exist, alocate it in case we need it later */ +- *pipe = shm_malloc(sizeof(rl_pipe_t)); +- if (!*pipe) { +- LM_ERR("no more shm memory\n"); ++ /* if the pipe does not exist, allocate it in case we need it later */ ++ if (!(*pipe = rl_create_pipe(limit, algo))) + goto release; +- } +- memset(*pipe, 0, sizeof(rl_pipe_t)); + LM_DBG("Pipe %.*s doesn't exist, but was created %p\n", + name.len, name.s, *pipe); +- (*pipe)->algo = algo; +- (*pipe)->limit = limit; ++ + } else { + LM_DBG("Pipe %.*s found: %p - last used %lu\n", + name.len, name.s, *pipe, (*pipe)->last_used); +@@ -919,6 +932,8 @@ void rl_rcv_bin(int packet_type, struct receive_info *ri, int server_id) + (*pipe)->last_used = time(0); + /* set the destination's counter */ + destination = find_destination(*pipe, server_id); ++ if (!destination) ++ goto release; + destination->counter = counter; + destination->update = now; + RL_RELEASE_LOCK(hash_idx); diff --git a/opensips-0032-acc-fix-possbile-memory-leak-when-calling-do_account.patch b/opensips-0032-acc-fix-possbile-memory-leak-when-calling-do_account.patch deleted file mode 100644 index fc3aaa6..0000000 --- a/opensips-0032-acc-fix-possbile-memory-leak-when-calling-do_account.patch +++ /dev/null @@ -1,42 +0,0 @@ -From: rvlad-patrascu -Date: Fri, 6 Oct 2017 19:47:12 +0300 -Subject: [PATCH] acc: fix possbile memory leak when calling do_accounting() on - CANCEL while "report_cancels" modparam not set - -(cherry picked from commit aa32bf1b6909c8471eea8c2170a3a2a3f94be1cf) - -Conflicts: - modules/acc/acc_logic.c - -diff --git a/modules/acc/acc_logic.c b/modules/acc/acc_logic.c -index 47daf4204..2072afb29 100644 ---- a/modules/acc/acc_logic.c -+++ b/modules/acc/acc_logic.c -@@ -1086,6 +1086,17 @@ int w_do_acc_3(struct sip_msg* msg, char* type_p, char* flags_p, char* table_p) - return -1; - } - -+ if (!msg) { -+ LM_ERR("no SIP message\n"); -+ return -1; -+ } -+ -+ if (skip_cancel(msg)) { -+ LM_WARN("do_accounting() called on CANCEL but 'report_cancels' modparam" -+ " not set - no accounting will be done for this transaction!\n"); -+ return 1; -+ } -+ - acc_param = (acc_type_param_t *)type_p; - if (acc_param->t == DO_ACC_PARAM_TYPE_VALUE) { - type = acc_param->u.ival; -@@ -1177,8 +1188,7 @@ int w_do_acc_3(struct sip_msg* msg, char* type_p, char* flags_p, char* table_p) - } - - -- if ( msg && !skip_cancel(msg) && -- (is_acc_on(*flag_mask_p) || is_mc_acc_on(*flag_mask_p)) ) { -+ if (is_acc_on(*flag_mask_p) || is_mc_acc_on(*flag_mask_p)) { - /* do some parsing in advance */ - if (acc_preparse_req(msg)<0) - return -1; diff --git a/opensips-0033-dialog-fix-a-runtime-bug-with-DLGCB_LOADED-callbacks.patch b/opensips-0033-dialog-fix-a-runtime-bug-with-DLGCB_LOADED-callbacks.patch deleted file mode 100644 index 0ee5852..0000000 --- a/opensips-0033-dialog-fix-a-runtime-bug-with-DLGCB_LOADED-callbacks.patch +++ /dev/null @@ -1,69 +0,0 @@ -From: rvlad-patrascu -Date: Fri, 13 Oct 2017 19:11:11 +0300 -Subject: [PATCH] dialog: fix a runtime bug with DLGCB_LOADED callbacks - -Relying on the fact that all modules that register dialog callbacks are initialised -after the dialog module (thanks to module dependencies), we can run all DLGCB_LOADED -callbacks at registration time and also keep them in a list for calling them later -(i.e reloading from database via MI cmd or receiving replicated dialog). - -This fixes a series of bugs where the DLGCB_LOADED callback is not run during, e.g. -"dlg_db_sync" MI command or received replicated dialogs which do not have their -callbacks installed or run. - -(cherry picked from commit 8c8f27f6091289061f6aaf0d3c85ccd27db80a0d) - -diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c -index 64b210e4e..9e827343a 100644 ---- a/modules/dialog/dialog.c -+++ b/modules/dialog/dialog.c -@@ -961,10 +961,8 @@ static int mod_init(void) - LM_ERR("failed to initialize the DB support\n"); - return -1; - } -- run_load_callbacks(); - } - -- mark_dlg_loaded_callbacks_run(); - destroy_cachedb(0); - - return 0; -diff --git a/modules/dialog/dlg_cb.c b/modules/dialog/dlg_cb.c -index d1cca0264..d5437cf50 100644 ---- a/modules/dialog/dlg_cb.c -+++ b/modules/dialog/dlg_cb.c -@@ -36,7 +36,6 @@ - - static struct dlg_head_cbl* create_cbs = 0; - --static int dlg_load_cbs_run = 0; - static struct dlg_head_cbl* load_cbs = 0; - - static struct dlg_cb_params params = {NULL, DLG_DIR_NONE, NULL, NULL}; -@@ -80,11 +79,6 @@ void destroy_dlg_callbacks_list(struct dlg_callback *cb) - } - } - --void mark_dlg_loaded_callbacks_run(void) --{ -- dlg_load_cbs_run = 1; --} -- - - void destroy_dlg_callbacks(unsigned int types) - { -@@ -161,11 +155,9 @@ int register_dlgcb(struct dlg_cell *dlg, int types, dialog_cb f, - create_cbs->first = cb; - create_cbs->types |= types; - } else if (types==DLGCB_LOADED) { -- if (dlg_load_cbs_run) { -- /* run the callback on the spot */ -- run_load_callback(cb); -- return 0; -- } -+ /* run the callback on the spot */ -+ run_load_callback(cb); -+ /* also insert callback in list to be able to run it later */ - if (load_cbs==0) { - /* not initialized yet */ - if ( (load_cbs=init_dlg_callback())==NULL ) { diff --git a/opensips-0034-dialog-also-share-module-flags-when-replicating-dial.patch b/opensips-0034-dialog-also-share-module-flags-when-replicating-dial.patch deleted file mode 100644 index dffbd39..0000000 --- a/opensips-0034-dialog-also-share-module-flags-when-replicating-dial.patch +++ /dev/null @@ -1,45 +0,0 @@ -From: rvlad-patrascu -Date: Mon, 16 Oct 2017 17:26:29 +0300 -Subject: [PATCH] dialog: also share module flags when replicating dialogs - -(cherry picked from commit ad35e7cedc44efd90c58f26a853585ece5883bac) - -Conflicts: - modules/dialog/dlg_replication.c - -diff --git a/modules/dialog/dlg_replication.c b/modules/dialog/dlg_replication.c -index 1eb94816c..c6c084eb2 100644 ---- a/modules/dialog/dlg_replication.c -+++ b/modules/dialog/dlg_replication.c -@@ -193,6 +193,7 @@ int dlg_replicated_create(struct dlg_cell *cell, str *ftag, str *ttag, int safe) - bin_pop_str(&vars); - bin_pop_str(&profiles); - bin_pop_int(&dlg->user_flags); -+ bin_pop_int(&dlg->mod_flags); - bin_pop_int(&dlg->flags); - bin_pop_int((void *) &dlg->tl.timeout); - bin_pop_int(&dlg->legs[DLG_CALLER_LEG].last_gen_cseq); -@@ -335,6 +336,7 @@ int dlg_replicated_update(void) - bin_pop_str(&vars); - bin_pop_str(&profiles); - bin_pop_int(&dlg->user_flags); -+ bin_pop_int(&dlg->mod_flags); - bin_pop_int(&dlg->flags); - - bin_pop_int(&timeout); -@@ -513,6 +515,7 @@ void replicate_dialog_created(struct dlg_cell *dlg) - bin_push_str(vars); - bin_push_str(profiles); - bin_push_int(dlg->user_flags); -+ bin_push_int(dlg->mod_flags); - bin_push_int(dlg->flags & - ~(DLG_FLAG_NEW|DLG_FLAG_CHANGED|DLG_FLAG_VP_CHANGED)); - bin_push_int((unsigned int)time(0) + dlg->tl.timeout - get_ticks()); -@@ -595,6 +598,7 @@ void replicate_dialog_updated(struct dlg_cell *dlg) - bin_push_str(vars); - bin_push_str(profiles); - bin_push_int(dlg->user_flags); -+ bin_push_int(dlg->mod_flags); - bin_push_int(dlg->flags & - ~(DLG_FLAG_NEW|DLG_FLAG_CHANGED|DLG_FLAG_VP_CHANGED)); - bin_push_int((unsigned int)time(0) + dlg->tl.timeout - get_ticks()); diff --git a/opensips-0035-Fix-escaping-URI-parameters-skip-alphanumerical-char.patch b/opensips-0035-Fix-escaping-URI-parameters-skip-alphanumerical-char.patch deleted file mode 100644 index b249423..0000000 --- a/opensips-0035-Fix-escaping-URI-parameters-skip-alphanumerical-char.patch +++ /dev/null @@ -1,105 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Tue, 17 Oct 2017 11:40:47 +0300 -Subject: [PATCH] Fix escaping URI parameters - skip alphanumerical chars. - -Reported by Ben Newlin on "user" mailing list. - -(cherry picked from commit b5094f0dc6a4f52555f9cca1ea9df7c846749482) - -diff --git a/strcommon.c b/strcommon.c -index 23e3299fa..58009b93c 100644 ---- a/strcommon.c -+++ b/strcommon.c -@@ -274,8 +274,7 @@ int escape_user(str *sin, str *sout) - LM_ERR("invalid escaped character <%u>\n", (unsigned int)*p); - return -1; - } -- if (isdigit((int)*p) || ((*p >= 'A') && (*p <= 'Z')) || -- ((*p >= 'a') && (*p <= 'z'))) -+ if (isalnum((int)*p)) - { - *at = *p; - } else { -@@ -358,42 +357,46 @@ int escape_param(str *sin, str *sout) - LM_ERR("invalid escaped character <%u>\n", (unsigned int)*p); - return -1; - } -- switch (*p) { -- /* unreserved chars */ -- case '-': -- case '_': -- case '.': -- case '!': -- case '~': -- case '*': -- case '\'': -- case '(': -- case ')': -- /* param unreserved chars */ -- case '[': -- case ']': -- case '/': -- case ':': -- case '&': -- case '+': -- case '$': -- *at = *p; -- break; -- default: -- *at++ = '%'; -- x = (*p) >> 4; -- if (x < 10) -- { -- *at++ = x + '0'; -- } else { -- *at++ = x - 10 + 'a'; -- } -- x = (*p) & 0x0f; -- if (x < 10) { -- *at = x + '0'; -- } else { -- *at = x - 10 + 'a'; -- } -+ if (isalnum((int)*p)) { -+ *at = *p; -+ } else { -+ switch (*p) { -+ /* unreserved chars */ -+ case '-': -+ case '_': -+ case '.': -+ case '!': -+ case '~': -+ case '*': -+ case '\'': -+ case '(': -+ case ')': -+ /* param unreserved chars */ -+ case '[': -+ case ']': -+ case '/': -+ case ':': -+ case '&': -+ case '+': -+ case '$': -+ *at = *p; -+ break; -+ default: -+ *at++ = '%'; -+ x = (*p) >> 4; -+ if (x < 10) -+ { -+ *at++ = x + '0'; -+ } else { -+ *at++ = x - 10 + 'a'; -+ } -+ x = (*p) & 0x0f; -+ if (x < 10) { -+ *at = x + '0'; -+ } else { -+ *at = x - 10 + 'a'; -+ } -+ } - } - at++; - p++; diff --git a/opensips-0036-Fix-init-of-the-cachedb-related-module-params.patch b/opensips-0036-Fix-init-of-the-cachedb-related-module-params.patch deleted file mode 100644 index 091d05b..0000000 --- a/opensips-0036-Fix-init-of-the-cachedb-related-module-params.patch +++ /dev/null @@ -1,34 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Thu, 19 Oct 2017 19:00:29 +0300 -Subject: [PATCH] Fix init of the cachedb related module params - -Init val_prefix, noval_prefix and size_prefix before general cachedb init. -Credits go to @Tinet-AaronAn -Closes #1203 - -(cherry picked from commit ec8d6a982a93d96fec8683426d2107bda67de66f) - -diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c -index 9e827343a..9dd32e5be 100644 ---- a/modules/dialog/dialog.c -+++ b/modules/dialog/dialog.c -@@ -782,15 +782,15 @@ static int mod_init(void) - - /* we are only interested in these parameters if the cachedb url was defined */ - if (cdb_url.s) { -+ cdb_val_prefix.len = strlen(cdb_val_prefix.s); -+ cdb_noval_prefix.len = strlen(cdb_noval_prefix.s); -+ cdb_size_prefix.len = strlen(cdb_size_prefix.s); - cdb_url.len = strlen(cdb_url.s); -+ - if (init_cachedb_utils() <0) { - LM_ERR("cannot init cachedb utils\n"); - return -1; - } -- -- cdb_val_prefix.len = strlen(cdb_val_prefix.s); -- cdb_noval_prefix.len = strlen(cdb_noval_prefix.s); -- cdb_size_prefix.len = strlen(cdb_size_prefix.s); - } - - /* allocate a slot in the processing context */ diff --git a/opensips-0037-db-do-not-compute-capabilities.patch b/opensips-0037-db-do-not-compute-capabilities.patch deleted file mode 100644 index e6f0727..0000000 --- a/opensips-0037-db-do-not-compute-capabilities.patch +++ /dev/null @@ -1,29 +0,0 @@ -From: Razvan Crainea -Date: Tue, 24 Oct 2017 11:30:20 +0300 -Subject: [PATCH] db: do not compute capabilities - -Do not compute capabilities for modules that pre-populate them. This -fixes an issue where the db engine was overwriting the db capabilities -of db_virtual. - -Thanks go to Jonathan Hulme for reporting and providing testing -environment - -(cherry picked from commit 0527560978028de80a51343714429e5a3d923919) - -diff --git a/db/db.c b/db/db.c -index f658a0b13..a05406761 100644 ---- a/db/db.c -+++ b/db/db.c -@@ -244,7 +244,10 @@ int db_bind_mod(const str* mod, db_func_t* mydbf) - dbf.insert_update = (db_insert_update_f)find_mod_export(tmp, - "db_insert_update", 2, 0); - } -- if(db_check_api(&dbf, tmp)!=0) -+ /* check if the module pre-populated the capabilities, or we need to -+ * compute them ourselves - we check for the INSERT capability, because -+ * it's the only one that should be exported by all modules */ -+ if(!DB_CAPABILITY(dbf, DB_CAP_INSERT) && db_check_api(&dbf, tmp)!=0) - goto error; - - *mydbf=dbf; /* copy */ diff --git a/opensips-0038-db_virtual-provide-DELETE-capabilities-for-ROUND-mod.patch b/opensips-0038-db_virtual-provide-DELETE-capabilities-for-ROUND-mod.patch deleted file mode 100644 index 23c6220..0000000 --- a/opensips-0038-db_virtual-provide-DELETE-capabilities-for-ROUND-mod.patch +++ /dev/null @@ -1,19 +0,0 @@ -From: Razvan Crainea -Date: Tue, 24 Oct 2017 11:33:17 +0300 -Subject: [PATCH] db_virtual: provide DELETE capabilities for ROUND mode - -(cherry picked from commit 4c7cbb7e06183b318393977f993b0ff31508cd4c) - -diff --git a/modules/db_virtual/db_virtual.h b/modules/db_virtual/db_virtual.h -index 92ec5d911..92ceca01b 100644 ---- a/modules/db_virtual/db_virtual.h -+++ b/modules/db_virtual/db_virtual.h -@@ -52,7 +52,7 @@ DB_CAP_DELETE | DB_CAP_UPDATE | DB_CAP_REPLACE | DB_CAP_FETCH | \ - DB_CAP_LAST_INSERTED_ID | DB_CAP_INSERT_UPDATE | DB_CAP_ASYNC_RAW_QUERY) - - #define DB_CAP_ROUND (0 | DB_CAP_QUERY | DB_CAP_RAW_QUERY | DB_CAP_INSERT | \ --DB_CAP_FETCH | \ -+DB_CAP_FETCH | DB_CAP_DELETE \ - DB_CAP_LAST_INSERTED_ID | DB_CAP_INSERT_UPDATE | DB_CAP_ASYNC_RAW_QUERY) - - enum DB_MODE {FAILOVER=0, PARALLEL, ROUND}; diff --git a/opensips-0039-db_virtual-fix-previous-commit.patch b/opensips-0039-db_virtual-fix-previous-commit.patch deleted file mode 100644 index 7af2c84..0000000 --- a/opensips-0039-db_virtual-fix-previous-commit.patch +++ /dev/null @@ -1,19 +0,0 @@ -From: Razvan Crainea -Date: Tue, 24 Oct 2017 11:38:14 +0300 -Subject: [PATCH] db_virtual: fix previous commit - -(cherry picked from commit f53a74f5a6d572d69fa7439a3762ca6c3faba751) - -diff --git a/modules/db_virtual/db_virtual.h b/modules/db_virtual/db_virtual.h -index 92ceca01b..08b2e004c 100644 ---- a/modules/db_virtual/db_virtual.h -+++ b/modules/db_virtual/db_virtual.h -@@ -52,7 +52,7 @@ DB_CAP_DELETE | DB_CAP_UPDATE | DB_CAP_REPLACE | DB_CAP_FETCH | \ - DB_CAP_LAST_INSERTED_ID | DB_CAP_INSERT_UPDATE | DB_CAP_ASYNC_RAW_QUERY) - - #define DB_CAP_ROUND (0 | DB_CAP_QUERY | DB_CAP_RAW_QUERY | DB_CAP_INSERT | \ --DB_CAP_FETCH | DB_CAP_DELETE \ -+DB_CAP_FETCH | DB_CAP_DELETE | \ - DB_CAP_LAST_INSERTED_ID | DB_CAP_INSERT_UPDATE | DB_CAP_ASYNC_RAW_QUERY) - - enum DB_MODE {FAILOVER=0, PARALLEL, ROUND}; diff --git a/opensips-0040-Fix-creating-the-profiles-list-in-the-dlg_list_ctx-M.patch b/opensips-0040-Fix-creating-the-profiles-list-in-the-dlg_list_ctx-M.patch deleted file mode 100644 index a203ad3..0000000 --- a/opensips-0040-Fix-creating-the-profiles-list-in-the-dlg_list_ctx-M.patch +++ /dev/null @@ -1,22 +0,0 @@ -From: Bogdan-Andrei Iancu -Date: Fri, 27 Oct 2017 18:57:11 +0300 -Subject: [PATCH] Fix creating the profiles list in the dlg_list_ctx MI command - -The profiles are not array, but list as they have different names for the nodes.Reported by Vladimir Dubov (@vovad) -Closes #1166 - -(cherry picked from commit 60d161d447ccf082aa1be7fbb2261c5548dcd3bf) - -diff --git a/modules/dialog/dlg_hash.c b/modules/dialog/dlg_hash.c -index 7938d4a5c..86d9f6af3 100644 ---- a/modules/dialog/dlg_hash.c -+++ b/modules/dialog/dlg_hash.c -@@ -1286,7 +1286,7 @@ static inline int internal_mi_print_dlg(struct mi_node *rpl, - } - /* print dlg profiles */ - if (dlg->profile_links) { -- node3 = add_mi_node_child(node1, MI_IS_ARRAY, "profiles", 8, 0, 0); -+ node3 = add_mi_node_child(node1, 0, "profiles", 8, 0, 0); - if(node3 == 0) - goto error; - for( dl=dlg->profile_links ; dl ; dl=dl->next) { diff --git a/opensips-0041-db_sqlite-let-the-DB-interface-determine-the-capabil.patch b/opensips-0041-db_sqlite-let-the-DB-interface-determine-the-capabil.patch deleted file mode 100644 index ed04990..0000000 --- a/opensips-0041-db_sqlite-let-the-DB-interface-determine-the-capabil.patch +++ /dev/null @@ -1,24 +0,0 @@ -From: Razvan Crainea -Date: Thu, 9 Nov 2017 10:15:56 +0200 -Subject: [PATCH] db_sqlite: let the DB interface determine the capabilities - -This prevens the module from advertising bogus capabilities - in this -case the sqlite module was saying that it has the ASYNC RAW queries -support, although it didn't. - -Reported by Wilhelm Lundgren on list - -(cherry picked from commit b9ca13a643e4c21aeba1fa9d88c57a054a290f64) - -diff --git a/modules/db_sqlite/db_sqlite.c b/modules/db_sqlite/db_sqlite.c -index 73098a02e..7feb8edd9 100644 ---- a/modules/db_sqlite/db_sqlite.c -+++ b/modules/db_sqlite/db_sqlite.c -@@ -120,7 +120,6 @@ int db_sqlite_bind_api(const str* mod, db_func_t *dbb) - dbb->last_inserted_id = db_last_inserted_id; - dbb->insert_update = db_insert_update; - -- dbb->cap = DB_CAP_ALL ^ DB_CAP_ASYNC_RAW_QUERY; - return 0; - } - diff --git a/opensips-0042-rtpengine-do-not-use-replace-bson-for-delete.patch b/opensips-0042-rtpengine-do-not-use-replace-bson-for-delete.patch deleted file mode 100644 index e5ecdca..0000000 --- a/opensips-0042-rtpengine-do-not-use-replace-bson-for-delete.patch +++ /dev/null @@ -1,48 +0,0 @@ -From: Razvan Crainea -Date: Thu, 9 Nov 2017 10:23:54 +0200 -Subject: [PATCH] rtpengine: do not use replace bson for delete - -Prevent the module for using replace-* attributes for any other -operation than offer or answer. This allows you to use the -rtpengine_manage() function easier. - -Reported by Edwin Hoff - -(cherry picked from commit d67fbb9809427cc4087563bbbebf556420f1f330) - -diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c -index 4d2ea81f5..de881e29d 100644 ---- a/modules/rtpengine/rtpengine.c -+++ b/modules/rtpengine/rtpengine.c -@@ -1149,9 +1149,12 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg, enu - break; - - case 14: -- if (str_eq(&key, "replace-origin")) -- bencode_list_add_string(ng_flags->replace, "origin"); -- else if (str_eq(&key, "address-family")) { -+ if (str_eq(&key, "replace-origin")) { -+ if (!ng_flags->replace) -+ LM_DBG("%.*s not supported for %d op\n", key.len, key.s, *op); -+ else -+ bencode_list_add_string(ng_flags->replace, "origin"); -+ } else if (str_eq(&key, "address-family")) { - err = "missing value"; - if (!val.s) - goto error; -@@ -1193,9 +1196,12 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg, enu - break; - - case 26: -- if (str_eq(&key, "replace-session-connection")) -- bencode_list_add_string(ng_flags->replace, "session-connection"); -- else -+ if (str_eq(&key, "replace-session-connection")) { -+ if (!ng_flags->replace) -+ LM_DBG("%.*s not supported for %d op\n", key.len, key.s, *op); -+ else -+ bencode_list_add_string(ng_flags->replace, "session-connection"); -+ } else - goto error; - break; - diff --git a/opensips-0043-usrloc-Fix-locking-for-contact_id-based-deletion.patch b/opensips-0043-usrloc-Fix-locking-for-contact_id-based-deletion.patch deleted file mode 100644 index 52e3515..0000000 --- a/opensips-0043-usrloc-Fix-locking-for-contact_id-based-deletion.patch +++ /dev/null @@ -1,58 +0,0 @@ -From: Liviu Chircu -Date: Thu, 26 Oct 2017 12:16:33 +0300 -Subject: [PATCH] usrloc: Fix locking for contact_id-based deletion - -The delete_ucontact_from_id(), get_ucontact_from_id() pair of functions -were masking possible code execution paths which would lead to unsafe memory -access. This, in turn, would cause the ping_checker_timer() job of nathelper to -occasionally crash and burn. - -Reported by solo@astercc.org. - -(cherry picked from commit 18a93c89aa1c32498689a6f6dd09911272c18896) - -diff --git a/modules/usrloc/dlist.c b/modules/usrloc/dlist.c -index c46f05d9d..6e0bbf58c 100644 ---- a/modules/usrloc/dlist.c -+++ b/modules/usrloc/dlist.c -@@ -823,6 +823,10 @@ int find_domain(str* _d, udomain_t** _p) - - /* - * retrieve the ucontact from a domain using the contact id -+ * -+ * Returns: -+ * NULL, if contact not found -+ * contact, *with grabbed ulslot lock* - */ - ucontact_t* get_ucontact_from_id(udomain_t *d, uint64_t contact_id, urecord_t **_r) - { -@@ -865,7 +869,6 @@ ucontact_t* get_ucontact_from_id(udomain_t *d, uint64_t contact_id, urecord_t ** - for (c = r->contacts; c != NULL; c = c->next) - if ((unsigned short)c->label == clabel) { - *_r = r; -- unlock_ulslot(d, sl); - return c; - } - } -@@ -878,7 +881,8 @@ int delete_ucontact_from_id(udomain_t *d, uint64_t contact_id, char is_replicate - { - ucontact_t *c, virt_c; - urecord_t *r; -- -+ unsigned int sl, rlabel; -+ unsigned short aorhash, clabel; - - /* if contact only in database */ - if (db_mode == DB_ONLY) { -@@ -916,6 +920,11 @@ int delete_ucontact_from_id(udomain_t *d, uint64_t contact_id, char is_replicate - mem_delete_ucontact(r, c); - } - -+ unpack_indexes(contact_id, &aorhash, &rlabel, &clabel); -+ -+ sl = aorhash & (d->size - 1); -+ unlock_ulslot(d, sl); -+ - return 0; - } - diff --git a/opensips-0044-usrloc-Fix-bad-logical-condition.patch b/opensips-0044-usrloc-Fix-bad-logical-condition.patch deleted file mode 100644 index be3d585..0000000 --- a/opensips-0044-usrloc-Fix-bad-logical-condition.patch +++ /dev/null @@ -1,24 +0,0 @@ -From: Liviu Chircu -Date: Thu, 16 Nov 2017 12:06:01 +0200 -Subject: [PATCH] usrloc: Fix bad logical condition -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Reported by Răzvan Crainea. - -(cherry picked from commit a644f1b370d61e60b2f4de20c9728564d8d8a06d) - -diff --git a/modules/usrloc/urecord.c b/modules/usrloc/urecord.c -index f14e43443..6e1b7ef26 100644 ---- a/modules/usrloc/urecord.c -+++ b/modules/usrloc/urecord.c -@@ -324,7 +324,7 @@ static inline int wb_timer(urecord_t* _r,query_list_t **ins_list) - ptr = ptr->next; - - /* Should we remove the contact from the database ? */ -- if (st_expired_ucontact(t) == 1 && (!(t->flags)&FL_MEM)) { -+ if (st_expired_ucontact(t) == 1 && !(t->flags & FL_MEM)) { - VAL_BIGINT(cid_vals+cid_len) = t->contact_id; - if ((++cid_len) == max_contact_delete) { - if (db_multiple_ucontact_delete(_r->domain, cid_keys, diff --git a/opensips-0045-Don-t-include-mysql-mysql_version.h-directly.patch b/opensips-0045-Don-t-include-mysql-mysql_version.h-directly.patch deleted file mode 100644 index ea12fbc..0000000 --- a/opensips-0045-Don-t-include-mysql-mysql_version.h-directly.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: Peter Lemenkov -Date: Tue, 21 Nov 2017 14:53:03 +0300 -Subject: [PATCH] Don't include directly - -Signed-off-by: Peter Lemenkov - -diff --git a/modules/db_mysql/dbase.c b/modules/db_mysql/dbase.c -index 002f79405..722b00d3f 100644 ---- a/modules/db_mysql/dbase.c -+++ b/modules/db_mysql/dbase.c -@@ -35,7 +35,6 @@ - #include - #include - #include --#include - #include "../../mem/mem.h" - #include "../../dprint.h" - #include "../../db/db_query.h" -diff --git a/modules/db_mysql/my_con.c b/modules/db_mysql/my_con.c -index cc7109be1..87fd0c53c 100644 ---- a/modules/db_mysql/my_con.c -+++ b/modules/db_mysql/my_con.c -@@ -22,7 +22,7 @@ - #include "my_con.h" - #include "db_mysql.h" - #include "dbase.h" --#include -+#include - #include "../../mem/mem.h" - #include "../../dprint.h" - #include "../../ut.h" diff --git a/opensips-2.2.5_json-c_013.patch b/opensips-2.2.5_json-c_013.patch deleted file mode 100644 index c658caf..0000000 --- a/opensips-2.2.5_json-c_013.patch +++ /dev/null @@ -1,245 +0,0 @@ -commit 57ae84b2d8b2e0af1a66d529e4e94b21f3df319d -Author: Björn Esser -Date: Tue Dec 12 15:31:53 2017 +0100 - - modules/json: Properly detect json-c version and adaptions for v0.13 - -diff --git a/modules/json/Makefile b/modules/json/Makefile -index 5c514655b..479bec701 100644 ---- a/modules/json/Makefile -+++ b/modules/json/Makefile -@@ -2,7 +2,7 @@ - # - # Memcached implementation for memcache API. - # --# -+# - # WARNING: do not run this directly, it should be run by the master Makefile - - include ../../Makefile.defs -@@ -23,8 +23,23 @@ ifeq ($(JSON_BUILDER),) - DEFS += -I$(LOCALBASE)/include -I$(SYSBASE)/include - LIBS += -L$(LOCALBASE)/lib -ljson - else -- JSON_LIB_VER = $(shell $(JSON_BUILDER) --modversion | sed "s/\.\([0-9]\)\./.0\1./g" | sed "s/\.\([0-9]\)\$$/.0\1/g" | tr -d "." | sed -e "s/^0*//" ) -- DEFS += $(shell $(JSON_BUILDER) --cflags) -DJSON_LIB_VERSION=$(JSON_LIB_VER) -+ JSON_PKG_VER = $(shell $(JSON_BUILDER) --modversion) -+ JSON_PKG_MAJOR = $(shell \ -+ ver_tmp=`echo '$(JSON_PKG_VER)' | cut -f1 -d.`; \ -+ if [ -z "$$ver_tmp" ]; then ver_tmp=0; fi; \ -+ echo "$$ver_tmp";) -+ JSON_PKG_MINOR = $(shell \ -+ ver_tmp=`echo '$(JSON_PKG_VER)' | cut -f2 -d.`; \ -+ if [ -z "$$ver_tmp" ]; then ver_tmp=0; fi; \ -+ echo "$$ver_tmp";) -+ JSON_PKG_MICRO = $(shell \ -+ ver_tmp=`echo '$(JSON_PKG_VER)' | cut -f3 -d.`; \ -+ if [ -z "$$ver_tmp" ]; then ver_tmp=0; fi; \ -+ echo "$$ver_tmp";) -+ DEFS += $(shell $(JSON_BUILDER) --cflags) \ -+ -DJSON_PKG_MAJOR=$(JSON_PKG_MAJOR) \ -+ -DJSON_PKG_MINOR=$(JSON_PKG_MINOR) \ -+ -DJSON_PKG_MICRO=$(JSON_PKG_MICRO) - LIBS += $(shell $(JSON_BUILDER) --libs) - endif - -diff --git a/modules/json/array_del.c b/modules/json/array_del.c -index b23f6d3b3..9be6e2f84 100644 ---- a/modules/json/array_del.c -+++ b/modules/json/array_del.c -@@ -22,27 +22,34 @@ - * History: - * --------- - * 2009-09-04 first version (andreidragus) -+ * 2017-12-12 use opensips_json_c_helper.h (besser82) - */ - --#include --#include -+#include "opensips_json_c_helper.h" - --void array_list_del_idx( struct array_list * arr, int idx) -+#if JSON_C_VERSION_NUM < JSON_C_VER_013 -+void array_list_del_idx(struct array_list * arr, int idx) - { - int i; - -- if( idx >= arr->length) -+ if(idx >= arr->length) - return; - - - arr->free_fn(arr->array[idx]); - arr->length--; - -- for( i=idx; ilength; i++ ) -+ for(i=idx; ilength; i++) - arr->array[i] = arr->array[i+1]; - }; -+#endif - - void json_object_array_del(struct json_object* obj, int idx) - { -+#if JSON_C_VERSION_NUM >= JSON_C_VER_013 -+ struct array_list * arr = json_object_get_array(obj); -+ array_list_del_idx(arr, idx, arr->length); -+#else - array_list_del_idx(obj->o.c_array, idx); -+#endif - }; -diff --git a/modules/json/json.c b/modules/json/json.c -index 452e4a801..c709e44cf 100644 ---- a/modules/json/json.c -+++ b/modules/json/json.c -@@ -22,6 +22,7 @@ - * History: - * --------- - * 2009-09-04 first version (andreidragus) -+ * 2017-12-12 use opensips_json_c_helper.h (besser82) - */ - - -@@ -43,14 +44,9 @@ - #include "../../mi/mi.h" - #include "../tm/tm_load.h" - #include "../rr/api.h" -+#include "opensips_json_c_helper.h" - - --#include --#include -- -- --#define JSON_BUFF_SIZE 4096 -- - enum - { - TAG_KEY = 1, -@@ -93,7 +89,7 @@ typedef struct _json_name - }json_name; - - pv_json_t * all; --char buff[JSON_BUFF_SIZE]; -+char buff[JSON_FILE_BUF_SIZE]; - - static int mod_init(void); - static int child_init(int ); -@@ -298,19 +294,16 @@ json_t * get_object(pv_json_t * var, pv_param_t* pvp , json_tag ** tag, - !json_object_is_type( cur_obj, json_type_object ) ) - goto error; - --#if JSON_LIB_VERSION < 10 -+#if JSON_C_VERSION_NUM >= JSON_C_VER_010 -+ if (!json_object_object_get_ex( cur_obj,buff, &cur_obj ) && -+ tag == NULL) -+ goto error; -+#else - cur_obj = json_object_object_get( cur_obj, buff ); - - if( cur_obj == NULL && tag == NULL) - goto error; --#else -- if (!json_object_object_get_ex( cur_obj,buff, &cur_obj ) && -- tag == NULL) -- goto error; - #endif -- -- -- - } - - if( cur_tag->type & TAG_IDX ) -@@ -418,7 +411,7 @@ int pv_get_json (struct sip_msg* msg, pv_param_t* pvp, pv_value_t* val) - { - val->flags = PV_VAL_STR; - val->rs.s = (char*)json_object_get_string( obj ); --#if JSON_LIB_VERSION >= 10 -+#if JSON_C_VERSION_NUM >= JSON_C_VER_010 - val->rs.len = json_object_get_string_len( obj ); - #else - val->rs.len = strlen(val->rs.s); -@@ -590,7 +583,7 @@ int pv_set_json (struct sip_msg* msg, pv_param_t* pvp, int flag , - if (obj == NULL) - { - LM_ERR("Error parsing json: %s\n", --#if JSON_LIB_VERSION >= 10 -+#if JSON_C_VERSION_NUM >= JSON_C_VER_010 - json_tokener_error_desc(parse_status) - #else - json_tokener_errors[(unsigned long)obj] -diff --git a/modules/json/opensips_json_c_helper.h b/modules/json/opensips_json_c_helper.h -new file mode 100644 -index 000000000..71c5c2189 ---- /dev/null -+++ b/modules/json/opensips_json_c_helper.h -@@ -0,0 +1,70 @@ -+/* -+ * Copyright (C) 2017 Björn Esser -+ * -+ * This file is part of opensips, a free SIP server. -+ * -+ * opensips is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * opensips is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ * -+ * -+ * History: -+ * --------- -+ * 2017-12-12 first version (besser82) -+ */ -+ -+#ifndef OPENSIPS_JSON_C_HELPER_H -+#define OPENSIPS_JSON_C_HELPER_H -+ -+// If those are not defined, we assume to build against json-c v0.9. -+// Starting with v0.11 there is json_c_version.h, which we prefer -+// anyways, so there are no regressions in this case. Everything -+// conditionalized for v0.10 or later doesn't produce any fallout, -+// when we are asuming v0.9 and building against v0.10. -+#ifndef JSON_PKG_MAJOR -+#define JSON_PKG_MAJOR 0 -+#endif -+#ifndef JSON_PKG_MINOR -+#define JSON_PKG_MINOR 9 -+#endif -+#ifndef JSON_PKG_MICRO -+#define JSON_PKG_MICRO 0 -+#endif -+ -+// json.h automatically includes json_c_version.h, if available. -+#include -+ -+// We prefer JSON_C_VERSION_NUM defined in json_c_version.h. If it is -+// not defined, we construct it the same way from our JSON_PKG_* defines. -+#ifndef JSON_C_VERSION_NUM -+#define JSON_C_VERSION_NUM (JSON_PKG_MAJOR << 16) | \ -+ (JSON_PKG_MINOR << 8) | \ -+ JSON_PKG_MICRO -+#endif -+ -+// Macros for checking specific versions. -+#define JSON_C_VER_010 (10 << 8) -+#define JSON_C_VER_013 (13 << 8) -+ -+// json_object_private.h is gone and not needed anymore in json-c v0.13+. -+#if JSON_C_VERSION_NUM < JSON_C_VER_013 -+#include -+#endif -+ -+// Newer versions of json-c define this in their headers, so we prefer -+// their definition in that case. -+#ifndef JSON_FILE_BUF_SIZE -+#define JSON_FILE_BUF_SIZE 4096 -+#endif -+ -+#endif // OPENSIPS_JSON_C_HELPER_H diff --git a/opensips.spec b/opensips.spec index 61dea2d..f1c4c0f 100644 --- a/opensips.spec +++ b/opensips.spec @@ -4,10 +4,9 @@ Summary: Open Source SIP Server Name: opensips -Version: 2.2.5 -Release: 8%{?dist} +Version: 2.2.6 +Release: 1%{?dist} License: GPLv2+ -Group: System Environment/Daemons Source0: https://github.com/%{name}/%{name}/archive/%{version}/%{name}-%{version}.tar.gz # Fedora-specific patches Patch1: opensips-0001-Consistently-use-rtpproxy-switches.patch @@ -24,43 +23,27 @@ Patch9: opensips-0009-Add-support-for-openssl-1.1.0.patch Patch10: opensips-0010-identity-add-support-for-openssl-1.1.0.patch Patch11: opensips-0011-identity-complete-port-to-openssl-1.1.0.patch Patch12: opensips-0012-Finalize-OpenSSL-1.1.0-migration.patch -Patch13: opensips-0013-Fix-milliseconds-for-call-duration-consistency-acros.patch -Patch14: opensips-0014-acc-restore-new_uri-in-case-an-error-occurs-on-reply.patch -Patch15: opensips-0015-drouting-fix-parameters-specifications-for-gw-detect.patch -Patch16: opensips-0016-Fix-incorrect-bug-log.patch -Patch17: opensips-0017-Fix-replicating-NULL-socket-in-contact.patch -Patch18: opensips-0018-b2b_entities-fix-b2b-key-memory-leak.patch -Patch19: opensips-0019-Fixed-wrong-TLS-parameters.patch -Patch20: opensips-0020-db_mysql-fix-build-against-MariaDB-10.2.patch -Patch21: opensips-0021-event_xmlrpc-rebuild-buffer-for-each-event.patch -Patch22: opensips-0022-dialog-do-not-allow-callbacks-in-state-DELETED.patch -Patch23: opensips-0023-ratelimit-fix-buffer-overflow-when-using-SBT-algorit.patch -Patch24: opensips-0024-siptrace-fix-type-for-message-DB-column-value-str-in.patch -Patch25: opensips-0025-parse_fline-fix-implicit-cast-sign.patch -Patch26: opensips-0026-proto_wss-write-all-TLS-chunks-under-a-single-lock.patch -Patch27: opensips-0027-proto_wss-release-lock-even-if-write-fails.patch -Patch28: opensips-0028-Fix-bogus-error-message-probabaly-copy-paste-error.patch -Patch29: opensips-0029-siptrace-allow-capturing-on-any-port.patch -Patch30: opensips-0030-Merge-pull-request-1191-from-etamme-master.patch -Patch31: opensips-0031-Merge-pull-request-1195-from-etamme-master.patch -Patch32: opensips-0032-acc-fix-possbile-memory-leak-when-calling-do_account.patch -Patch33: opensips-0033-dialog-fix-a-runtime-bug-with-DLGCB_LOADED-callbacks.patch -Patch34: opensips-0034-dialog-also-share-module-flags-when-replicating-dial.patch -Patch35: opensips-0035-Fix-escaping-URI-parameters-skip-alphanumerical-char.patch -Patch36: opensips-0036-Fix-init-of-the-cachedb-related-module-params.patch -Patch37: opensips-0037-db-do-not-compute-capabilities.patch -Patch38: opensips-0038-db_virtual-provide-DELETE-capabilities-for-ROUND-mod.patch -Patch39: opensips-0039-db_virtual-fix-previous-commit.patch -Patch40: opensips-0040-Fix-creating-the-profiles-list-in-the-dlg_list_ctx-M.patch -Patch41: opensips-0041-db_sqlite-let-the-DB-interface-determine-the-capabil.patch -Patch42: opensips-0042-rtpengine-do-not-use-replace-bson-for-delete.patch -Patch43: opensips-0043-usrloc-Fix-locking-for-contact_id-based-deletion.patch -Patch44: opensips-0044-usrloc-Fix-bad-logical-condition.patch -Patch45: opensips-0045-Don-t-include-mysql-mysql_version.h-directly.patch - -# For building against libjson-c-0.13 -# Upstreamed: https://github.com/OpenSIPS/opensips/pull/1230 -Patch100: opensips-2.2.5_json-c_013.patch +Patch13: opensips-0013-modules-json-Properly-detect-json-c-version-and-adap.patch +Patch14: opensips-0014-Add-sys-uio.h-where-writev-2-is-used.patch +Patch15: opensips-0015-sst-fix-MIN-SE-header-printing.patch +Patch16: opensips-0016-sms-prevent-buffer-overrun.patch +Patch17: opensips-0017-sms-increase-pin-buffer-to-avoid-warnings.patch + +# Backported from 2.2 branch +Patch18: opensips-0018-pvar-fix-hdr-to-allow-variable-headers.patch +Patch19: opensips-0019-ratelimit-replicate-the-current-counter-for-SBT.patch +Patch20: opensips-0020-cfg-fix-error-reporting-for-unenclosed-scriptvars.patch +Patch21: opensips-0021-event_flatstore-fix-possible-crash-when-subscribing.patch +Patch22: opensips-0022-event_flatstore-fix-some-locking-issues.patch +Patch23: opensips-0023-event_flatstore-return-proper-error-message-for-evi_.patch +Patch24: opensips-0024-Fix-reverse_hex2int-prototype.patch +Patch25: opensips-0025-Explicit-reset-of-conn-ID-on-error.patch +Patch26: opensips-0026-Fix-reverse_hex2int64-prototype.patch +Patch27: opensips-0027-rtpproxy-fix-test-condition-for-altering-IP-in-SDP-w.patch +Patch28: opensips-0028-nathelper-manual-backport-for-3c39167e333a8801772f49.patch +Patch29: opensips-0029-nathelper-revert-commit-a45d4dcaf046bb273cfe5905ac03.patch +Patch30: opensips-0030-rtpproxy-revert-commit-ee2731212303eb7055b3bd165464f.patch +Patch31: opensips-0031-ratelimit-create-pipe-in-a-generic-manner.patch URL: https://opensips.org @@ -820,7 +803,7 @@ done # install systemd files install -D -m 0644 -p packaging/redhat_fedora/%{name}.service %{buildroot}%{_unitdir}/%{name}.service install -D -m 0644 -p packaging/redhat_fedora/%{name}.tmpfiles.conf %{buildroot}%{_tmpfilesdir}/%{name}.conf -install -D -m 0755 -p packaging/redhat_fedora/%{name}.m4cfg %{buildroot}%{_sbindir}/opensips-m4cfg +install -D -m 0755 -p packaging/redhat_fedora/%{name}-m4cfg %{buildroot}%{_sbindir}/opensips-m4cfg mkdir -p %{buildroot}%{_localstatedir}/run/%{name} echo -e "\nETCDIR=\"%{_sysconfdir}/opensips\"\n" \ >> %{buildroot}%{_sysconfdir}/%{name}/opensipsctlrc @@ -1373,6 +1356,9 @@ useradd -r -g %{name} -d %{_localstatedir}/run/%{name} -s /sbin/nologin \ %doc docdir/README.xmpp %changelog +* Tue Feb 13 2018 Peter Lemenkov - 2.2.6-1 +- Ver. 2.2.6 + * Thu Feb 08 2018 Fedora Release Engineering - 2.2.5-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild diff --git a/sources b/sources index 7a58a97..1ac265e 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (opensips-2.2.5.tar.gz) = 1b4a8ecf6793a1489b995ab808ebb89a00e8c777686309acdcea3a1c93a839a0e68798eff290b247ce899f23e072a5c97de7e4f7bba6475e3b1a1f93d69edbdc +SHA512 (opensips-2.2.6.tar.gz) = bcdb3890f8e6a306cf94d6e8b8981551fc02794d18f86d7630fecc4c973e823cfff537a9425a7ef5a8122a94c9f15ef542144790a6b6e213a763261d81ddf208