Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEriks Sneiders <eriks.sneiders@zabbix.com>2022-05-06 12:30:25 +0300
committerEriks Sneiders <eriks.sneiders@zabbix.com>2022-05-06 12:30:25 +0300
commiteb9be057b33e024cf7379672d678587aa2842583 (patch)
tree74ed265b47172eca110d89ef20035b92119be7fe /src
parentc4e6eea367e400d780f79bb4f1c5cc145e3582a3 (diff)
parent1c6f94e807bed4d5effc9e88329c61ee51534a79 (diff)
.......... [DEV-2061] updated branch to current release 6.0
Diffstat (limited to 'src')
-rw-r--r--src/go/internal/agent/serverconnector/serverconnector.go2
-rw-r--r--src/go/pkg/glexpr/expression.go8
-rw-r--r--src/go/pkg/tls/tls.go13
-rw-r--r--src/go/pkg/version/version.go4
-rw-r--r--src/libs/zbxcrypto/sha256crypt.c9
-rw-r--r--src/libs/zbxcrypto/tls.c28
-rw-r--r--src/libs/zbxcrypto/tls_tcp.h4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5050.c24
-rw-r--r--src/libs/zbxembed/global.c68
-rw-r--r--src/libs/zbxembed/httprequest.c4
-rw-r--r--src/zabbix_agent/active.c3
-rw-r--r--src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java4
-rw-r--r--src/zabbix_server/lld/lld_item.c32
13 files changed, 105 insertions, 98 deletions
diff --git a/src/go/internal/agent/serverconnector/serverconnector.go b/src/go/internal/agent/serverconnector/serverconnector.go
index 73593e26812..4c1bb713601 100644
--- a/src/go/internal/agent/serverconnector/serverconnector.go
+++ b/src/go/internal/agent/serverconnector/serverconnector.go
@@ -284,7 +284,7 @@ func (c *Connector) refreshActiveChecks() {
return
}
- if len(*response.Expressions[i].Delimiter) != 1 {
+ if len(*response.Expressions[i].Delimiter) > 1 {
log.Errf(`[%d] cannot parse list of active checks from [%s]: invalid tag "exp_delimiter" value "%s"`,
c.clientID, c.addresses[0], *response.Expressions[i].Delimiter)
return
diff --git a/src/go/pkg/glexpr/expression.go b/src/go/pkg/glexpr/expression.go
index 44d328a3530..3f2ab0b48b5 100644
--- a/src/go/pkg/glexpr/expression.go
+++ b/src/go/pkg/glexpr/expression.go
@@ -86,7 +86,13 @@ func NewBundle(expressions []*Expression) (bundle *Bundle) {
bundle = &Bundle{expressions: expressions}
bundle.Cblob = zbxlib.NewGlobalRegexp()
for _, e := range expressions {
- zbxlib.AddGlobalRegexp(bundle.Cblob, e.Name, e.Body, *e.Type, (*e.Delimiter)[0], *e.Mode)
+ var delimeter byte = ','
+
+ if 0 != len(*e.Delimiter) {
+ delimeter = (*e.Delimiter)[0]
+ }
+
+ zbxlib.AddGlobalRegexp(bundle.Cblob, e.Name, e.Body, *e.Type, delimeter, *e.Mode)
}
runtime.SetFinalizer(bundle, func(b *Bundle) { zbxlib.DestroyGlobalRegexp(b.Cblob) })
return
diff --git a/src/go/pkg/tls/tls.go b/src/go/pkg/tls/tls.go
index 096e5a8f5cf..d5995820e1f 100644
--- a/src/go/pkg/tls/tls.go
+++ b/src/go/pkg/tls/tls.go
@@ -282,9 +282,18 @@ static unsigned int tls_psk_server_cb(SSL *ssl, const char *identity, unsigned c
static int zbx_set_ecdhe_parameters(SSL_CTX *ctx)
{
- EC_KEY *ecdh;
long res;
int ret = 0;
+#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_NUMBER >= 3 // OpenSSL 3.0.0 or newer
+#define ARRSIZE(a) (sizeof(a) / sizeof(*a))
+
+ int grp_list[1] = { NID_X9_62_prime256v1 }; // use curve secp256r1/prime256v1/NIST P-256
+
+ if (1 != (res = SSL_CTX_set1_groups(ctx, grp_list, ARRSIZE(grp_list))))
+ ret = -1;
+#undef ARRSIZE
+#else
+ EC_KEY *ecdh;
// use curve secp256r1/prime256v1/NIST P-256
@@ -297,7 +306,7 @@ static int zbx_set_ecdhe_parameters(SSL_CTX *ctx)
ret = -1;
EC_KEY_free(ecdh);
-
+#endif
return ret;
}
diff --git a/src/go/pkg/version/version.go b/src/go/pkg/version/version.go
index b0735954730..7068975ca34 100644
--- a/src/go/pkg/version/version.go
+++ b/src/go/pkg/version/version.go
@@ -26,10 +26,10 @@ import (
)
const (
- ZABBIX_REVDATE = "4 April 2022"
+ ZABBIX_REVDATE = "3 May 2022"
ZABBIX_VERSION_MAJOR = 6
ZABBIX_VERSION_MINOR = 0
- ZABBIX_VERSION_PATCH = 4
+ ZABBIX_VERSION_PATCH = 5
ZABBIX_VERSION_RC = "rc1"
ZABBIX_VERSION_RC_NUM = "{ZABBIX_RC_NUM}"
ZABBIX_VERSION_REVISION = "{ZABBIX_REVISION}"
diff --git a/src/libs/zbxcrypto/sha256crypt.c b/src/libs/zbxcrypto/sha256crypt.c
index 0317226a747..aaf0e059bbf 100644
--- a/src/libs/zbxcrypto/sha256crypt.c
+++ b/src/libs/zbxcrypto/sha256crypt.c
@@ -305,6 +305,15 @@ void zbx_sha256_hash(const char *in, char *out)
sha256_finish_ctx (&ctx, out);
}
+void zbx_sha256_hash_len(const char *in, size_t len, char *out)
+{
+ sha256_ctx ctx;
+
+ sha256_init_ctx(&ctx);
+ sha256_process_bytes (in, len, &ctx);
+ sha256_finish_ctx(&ctx, out);
+}
+
/* helper functions for sha256 hmac*/
typedef struct
diff --git a/src/libs/zbxcrypto/tls.c b/src/libs/zbxcrypto/tls.c
index 7e80be93079..5abc4b398d0 100644
--- a/src/libs/zbxcrypto/tls.c
+++ b/src/libs/zbxcrypto/tls.c
@@ -311,7 +311,7 @@ static void zbx_openssl_info_cb(const SSL *ssl, int where, int ret)
* *
******************************************************************************/
#if defined(HAVE_OPENSSL)
-void zbx_tls_error_msg(char **error, size_t *error_alloc, size_t *error_offset)
+static void zbx_tls_error_msg(char **error, size_t *error_alloc, size_t *error_offset)
{
unsigned long error_code;
const char *file, *data;
@@ -319,13 +319,22 @@ void zbx_tls_error_msg(char **error, size_t *error_alloc, size_t *error_offset)
char err[1024];
/* concatenate all error messages in the queue into one string */
+#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_NUMBER >= 3 /* OpenSSL 3.0.0 or newer */
+ const char *func;
+ while (0 != (error_code = ERR_get_error_all(&file, &line, &func, &data, &flags)))
+#else /* OpenSSL 1.x.x or LibreSSL */
while (0 != (error_code = ERR_get_error_line_data(&file, &line, &data, &flags)))
+#endif
{
ERR_error_string_n(error_code, err, sizeof(err));
+#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_NUMBER >= 3 /* OpenSSL 3.0.0 or newer */
+ zbx_snprintf_alloc(error, error_alloc, error_offset, " file %s line %d func %s: %s",
+ file, line, func, err);
+#else /* OpenSSL 1.x.x or LibreSSL */
zbx_snprintf_alloc(error, error_alloc, error_offset, " file %s line %d: %s", file, line, err);
-
+#endif
if (NULL != data && 0 != (flags & ERR_TXT_STRING))
zbx_snprintf_alloc(error, error_alloc, error_offset, ": %s", data);
}
@@ -2466,12 +2475,21 @@ static const char *zbx_ctx_name(SSL_CTX *param)
static int zbx_set_ecdhe_parameters(SSL_CTX *ctx)
{
const char *msg = "Perfect Forward Secrecy ECDHE ciphersuites will not be available for";
- EC_KEY *ecdh;
long res;
int ret = SUCCEED;
+#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_NUMBER >= 3 /* OpenSSL 3.0.0 or newer */
+ int grp_list[1] = { NID_X9_62_prime256v1 }; /* use curve secp256r1/prime256v1/NIST P-256 */
- /* use curve secp256r1/prime256v1/NIST P-256 */
+ if (1 != (res = SSL_CTX_set1_groups(ctx, grp_list, ARRSIZE(grp_list))))
+ {
+ zabbix_log(LOG_LEVEL_WARNING, "%s() SSL_CTX_set1_groups() returned %ld. %s %s",
+ __func__, res, msg, zbx_ctx_name(ctx));
+ ret = FAIL;
+ }
+#else /* OpenSSL 1.x.x or LibreSSL */
+ EC_KEY *ecdh;
+ /* use curve secp256r1/prime256v1/NIST P-256 */
if (NULL == (ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1)))
{
zabbix_log(LOG_LEVEL_WARNING, "%s() EC_KEY_new_by_curve_name() failed. %s %s",
@@ -2489,7 +2507,7 @@ static int zbx_set_ecdhe_parameters(SSL_CTX *ctx)
}
EC_KEY_free(ecdh);
-
+#endif
return ret;
}
diff --git a/src/libs/zbxcrypto/tls_tcp.h b/src/libs/zbxcrypto/tls_tcp.h
index 1aacf483e83..90bc460275c 100644
--- a/src/libs/zbxcrypto/tls_tcp.h
+++ b/src/libs/zbxcrypto/tls_tcp.h
@@ -29,8 +29,4 @@ ssize_t zbx_tls_read(zbx_socket_t *s, char *buf, size_t len, char **error);
void zbx_tls_close(zbx_socket_t *s);
#endif
-#if defined(HAVE_OPENSSL)
-void zbx_tls_error_msg(char **error, size_t *error_alloc, size_t *error_offset);
-#endif
-
#endif /* ZABBIX_TLS_TCP_H */
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5050.c b/src/libs/zbxdbupgrade/dbupgrade_5050.c
index 8aefd3c6f13..901b626cc7a 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5050.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5050.c
@@ -336,28 +336,6 @@ static int DBpatch_5050031(void)
return DBadd_field("config", &field);
}
-static int DBpatch_5050032(void)
-{
- if (0 == (program_type & ZBX_PROGRAM_TYPE_SERVER))
- return SUCCEED;
-
- if (ZBX_DB_OK > DBexecute("update config set default_lang='en_US' where default_lang='en_GB'"))
- return FAIL;
-
- return SUCCEED;
-}
-
-static int DBpatch_5050033(void)
-{
- if (0 == (program_type & ZBX_PROGRAM_TYPE_SERVER))
- return SUCCEED;
-
- if (ZBX_DB_OK > DBexecute("update users set lang='en_US' where lang='en_GB'"))
- return FAIL;
-
- return SUCCEED;
-}
-
static int DBpatch_5050034(void)
{
const ZBX_FIELD field = {"default_lang", "en_US", NULL, NULL, 5, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
@@ -1985,8 +1963,6 @@ DBPATCH_ADD(5050023, 0, 1)
DBPATCH_ADD(5050024, 0, 1)
DBPATCH_ADD(5050030, 0, 1)
DBPATCH_ADD(5050031, 0, 1)
-DBPATCH_ADD(5050032, 0, 1)
-DBPATCH_ADD(5050033, 0, 1)
DBPATCH_ADD(5050034, 0, 1)
DBPATCH_ADD(5050040, 0, 1)
DBPATCH_ADD(5050041, 0, 1)
diff --git a/src/libs/zbxembed/global.c b/src/libs/zbxembed/global.c
index d8af3902419..9dee353d98e 100644
--- a/src/libs/zbxembed/global.c
+++ b/src/libs/zbxembed/global.c
@@ -80,6 +80,29 @@ static duk_ret_t es_atob(duk_context *ctx)
/******************************************************************************
* *
+ * Purpose: convert binary data to hex string *
+ * *
+ * Parameters: bin - [IN] the data to convert *
+ * len - [IN] the number of bytes to convert *
+ * out - [OUT] the output buffer (must be 2x + 1 of input len) *
+ * *
+ ******************************************************************************/
+static void es_bin_to_hex(const unsigned char *bin, size_t len, char *out)
+{
+ const char *hex = "0123456789abcdef";
+ size_t i;
+
+ for (i = 0; i < len; i++)
+ {
+ *out++ = hex[bin[i] >> 4];
+ *out++ = hex[bin[i] & 15];
+ }
+
+ *out = '\0';
+}
+
+/******************************************************************************
+ * *
* Purpose: compute a md5 checksum *
* *
* Parameters: ctx - [IN] pointer to duk_context *
@@ -91,31 +114,23 @@ static duk_ret_t es_atob(duk_context *ctx)
******************************************************************************/
static duk_ret_t es_md5(duk_context *ctx)
{
- const char *hex = "0123456789abcdef";
+ const char *str;
md5_state_t state;
md5_byte_t hash[MD5_DIGEST_SIZE];
- int i;
- char *str = NULL, *md5sum, *ptr;
+ char *md5sum;
+ duk_size_t len;
- if (SUCCEED != zbx_cesu8_to_utf8(duk_require_string(ctx, 0), &str))
- return duk_error(ctx, DUK_RET_TYPE_ERROR, "cannot convert value to utf8");
+ str = duk_require_lstring(ctx, 0, &len);
- ptr = md5sum = (char *)zbx_malloc(NULL, MD5_DIGEST_SIZE * 2 + 1);
+ md5sum = (char *)zbx_malloc(NULL, MD5_DIGEST_SIZE * 2 + 1);
zbx_md5_init(&state);
- zbx_md5_append(&state, (const md5_byte_t *)str, strlen(str));
+ zbx_md5_append(&state, (const md5_byte_t *)str, (int)len);
zbx_md5_finish(&state, hash);
- for (i = 0; i < MD5_DIGEST_SIZE; i++)
- {
- *ptr++ = hex[hash[i] >> 4];
- *ptr++ = hex[hash[i] & 15];
- }
-
- *ptr = '\0';
+ es_bin_to_hex(hash, MD5_DIGEST_SIZE, md5sum);
duk_push_string(ctx, md5sum);
- zbx_free(str);
zbx_free(md5sum);
return 1;
}
@@ -133,27 +148,16 @@ static duk_ret_t es_md5(duk_context *ctx)
******************************************************************************/
static duk_ret_t es_sha256(duk_context *ctx)
{
- char *str = NULL, hash_res[ZBX_SHA256_DIGEST_SIZE], hash_res_stringhexes[ZBX_SHA256_DIGEST_SIZE * 2 + 1];
- int i;
-
- if (SUCCEED != zbx_cesu8_to_utf8(duk_require_string(ctx, 0), &str))
- return duk_error(ctx, DUK_RET_TYPE_ERROR, "cannot convert value to utf8");
+ const char *str;
+ char hash_res[ZBX_SHA256_DIGEST_SIZE], hash_res_stringhexes[ZBX_SHA256_DIGEST_SIZE * 2 + 1];
+ duk_size_t len;
- zbx_sha256_hash(str, hash_res);
+ str = duk_require_lstring(ctx, 0, &len);
- for (i = 0 ; i < ZBX_SHA256_DIGEST_SIZE; i++)
- {
- char z[3];
-
- zbx_snprintf(z, 3, "%02x", (unsigned char)hash_res[i]);
- hash_res_stringhexes[i * 2] = z[0];
- hash_res_stringhexes[i * 2 + 1] = z[1];
- }
-
- hash_res_stringhexes[ZBX_SHA256_DIGEST_SIZE * 2] = '\0';
+ zbx_sha256_hash_len(str, len, hash_res);
+ es_bin_to_hex((const unsigned char *)hash_res, ZBX_SHA256_DIGEST_SIZE, hash_res_stringhexes);
duk_push_string(ctx, hash_res_stringhexes);
- zbx_free(str);
return 1;
}
diff --git a/src/libs/zbxembed/httprequest.c b/src/libs/zbxembed/httprequest.c
index 18892e800c7..9a56a0952ef 100644
--- a/src/libs/zbxembed/httprequest.c
+++ b/src/libs/zbxembed/httprequest.c
@@ -71,7 +71,7 @@ static size_t curl_write_cb(void *ptr, size_t size, size_t nmemb, void *userdata
size_t r_size = size * nmemb;
zbx_es_httprequest_t *request = (zbx_es_httprequest_t *)userdata;
- zbx_strncpy_alloc(&request->data, &request->data_alloc, &request->data_offset, (const char *)ptr, r_size);
+ zbx_str_memcpy_alloc(&request->data, &request->data_alloc, &request->data_offset, (const char *)ptr, r_size);
return r_size;
}
@@ -331,7 +331,7 @@ out:
if (-1 != err_index)
return duk_throw(ctx);
- duk_push_string(ctx, request->data);
+ duk_push_lstring(ctx, request->data, request->data_offset);
return 1;
}
diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c
index 7a1ec415975..756d6e0ef5f 100644
--- a/src/zabbix_agent/active.c
+++ b/src/zabbix_agent/active.c
@@ -1458,7 +1458,8 @@ ZBX_THREAD_ENTRY(active_checks_thread, args)
zbx_free(session_token);
#ifdef _WINDOWS
- zbx_addr_free(&activechk_args.addrs);
+ zbx_vector_ptr_clear_ext(&activechk_args.addrs, (zbx_clean_func_t)zbx_addr_free);
+ zbx_vector_ptr_destroy(&activechk_args.addrs);
free_active_metrics();
ZBX_DO_EXIT();
diff --git a/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java b/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java
index 27278a7e5ac..9ef179f26be 100644
--- a/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java
+++ b/src/zabbix_java/src/com/zabbix/gateway/GeneralInformation.java
@@ -22,9 +22,9 @@ package com.zabbix.gateway;
class GeneralInformation
{
static final String APPLICATION_NAME = "Zabbix Java Gateway";
- static final String REVISION_DATE = "4 April 2022";
+ static final String REVISION_DATE = "3 May 2022";
static final String REVISION = "{ZABBIX_REVISION}";
- static final String VERSION = "6.0.4rc1";
+ static final String VERSION = "6.0.5rc1";
static void printVersion()
{
diff --git a/src/zabbix_server/lld/lld_item.c b/src/zabbix_server/lld/lld_item.c
index bc0948b67d9..2ea606e3c73 100644
--- a/src/zabbix_server/lld/lld_item.c
+++ b/src/zabbix_server/lld/lld_item.c
@@ -1838,14 +1838,6 @@ static void lld_items_validate(zbx_uint64_t hostid, zbx_vector_ptr_t *items, zbx
continue;
}
-
- if (0 != item->master_itemid && (FAIL != zbx_vector_ptr_bsearch(item_prototypes, &item->master_itemid,
- ZBX_DEFAULT_UINT64_PTR_COMPARE_FUNC)))
- {
- item->flags &= ~ZBX_FLAG_LLD_ITEM_DISCOVERED;
- *error = zbx_strdcatf(*error, "Cannot %s dependent item: master item is not discovered.\n",
- (0 != item->itemid ? "update" : "create"));
- }
}
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
@@ -2087,7 +2079,6 @@ static zbx_lld_item_t *lld_item_make(const zbx_lld_item_prototype_t *item_protot
item->publickey_orig = NULL;
item->privatekey_orig = NULL;
- item->flags = ZBX_FLAG_LLD_ITEM_DISCOVERED;
item->lld_row = lld_row;
zbx_vector_ptr_create(&item->preproc_ops);
@@ -2095,11 +2086,10 @@ static zbx_lld_item_t *lld_item_make(const zbx_lld_item_prototype_t *item_protot
zbx_vector_ptr_create(&item->item_params);
zbx_vector_ptr_create(&item->item_tags);
- if (SUCCEED != ret || ZBX_PROTOTYPE_NO_DISCOVER == discover)
- {
- lld_item_free(item);
- item = NULL;
- }
+ if (SUCCEED == ret && ZBX_PROTOTYPE_NO_DISCOVER != discover)
+ item->flags = ZBX_FLAG_LLD_ITEM_DISCOVERED;
+ else
+ item->flags = 0;
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
@@ -2545,14 +2535,12 @@ static void lld_items_make(const zbx_vector_ptr_t *item_prototypes, zbx_vector_p
if (NULL == (item_index = (zbx_lld_item_index_t *)zbx_hashset_search(items_index, &item_index_local)))
{
- if (NULL != (item = lld_item_make(item_prototype, item_index_local.lld_row,
- lld_macro_paths, error)))
- {
- /* add the created item to items vector and update index */
- zbx_vector_ptr_append(items, item);
- item_index_local.item = item;
- zbx_hashset_insert(items_index, &item_index_local, sizeof(item_index_local));
- }
+ item = lld_item_make(item_prototype, item_index_local.lld_row, lld_macro_paths, error);
+
+ /* add the created item to items vector and update index */
+ zbx_vector_ptr_append(items, item);
+ item_index_local.item = item;
+ zbx_hashset_insert(items_index, &item_index_local, sizeof(item_index_local));
}
else
lld_item_update(item_prototype, item_index_local.lld_row, lld_macro_paths, item_index->item, error);