diff options
author | Sergey Simonenko <sergey.simonenko@zabbix.com> | 2022-01-13 14:18:49 +0300 |
---|---|---|
committer | Sergey Simonenko <sergey.simonenko@zabbix.com> | 2022-01-13 14:18:49 +0300 |
commit | ac0f1a5fdcb8f08ff2919a8a5319d167dd7b0ec8 (patch) | |
tree | 042384f292d7c43545ae258c240a5a1009d63a14 /src | |
parent | ddb066b9a12879c2dca8de38eb5c529f8c9f7829 (diff) | |
parent | e4b285de093d747af9c0a6e488c16bb118a85c8d (diff) |
........S. [ZBX-19456] fixed zero timeshift
Merge in ZBX/zabbix from feature/ZBX-19456-5.4 to release/5.4
* commit 'e4b285de093d747af9c0a6e488c16bb118a85c8d':
........S. [ZBX-19456] changed zbx_trends_parse_range() behavior for zero time period, added test cases
........S. [ZBX-19456] changed zbx_trends_parse_range() behavior for zero time period, added test cases
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/zbxcommon/time.c | 2 | ||||
-rw-r--r-- | src/libs/zbxtrends/trends.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/libs/zbxcommon/time.c b/src/libs/zbxcommon/time.c index d7bbd4de211..f4f161d3643 100644 --- a/src/libs/zbxcommon/time.c +++ b/src/libs/zbxcommon/time.c @@ -71,7 +71,7 @@ int zbx_tm_parse_period(const char *period, size_t *len, int *multiplier, zbx_ti for (ptr = period; 0 != isdigit(*ptr); ptr++) ; - if (FAIL == is_uint_n_range(period, ptr - period, multiplier, sizeof(*multiplier), 1, UINT32_MAX)) + if (FAIL == is_uint_n_range(period, ptr - period, multiplier, sizeof(*multiplier), 0, UINT32_MAX)) { *error = zbx_strdup(*error, "invalid period multiplier"); return FAIL; diff --git a/src/libs/zbxtrends/trends.c b/src/libs/zbxtrends/trends.c index 3fd54424f8e..63bea2988a6 100644 --- a/src/libs/zbxtrends/trends.c +++ b/src/libs/zbxtrends/trends.c @@ -270,6 +270,12 @@ int zbx_trends_parse_range(time_t from, const char *param, int *start, int *end, return FAIL; } + if (0 == period_num) + { + *error = zbx_strdup(*error, "period cannot be zero"); + return FAIL; + } + if (period_hours[period_unit] * period_num > 24 * 366) { *error = zbx_strdup(*error, "period is too large"); |