summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2022-08-27 18:50:48 +0300
committerGitHub <noreply@github.com>2022-08-27 18:50:48 +0300
commit84b07e6e286ffa6db4f9f9d082e886e609bb6104 (patch)
treed3b95bad73d689c14ca9d8edebaea3f7f8eeef9b /database
parent96e64963ef866cc7c008310ee822228d4e1e6777 (diff)
prevent crash on rrdcontext apis when rrdcontexts is not initialized (#13578)
prevent crash
Diffstat (limited to 'database')
-rw-r--r--database/rrdcontext.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/database/rrdcontext.c b/database/rrdcontext.c
index 3444178e5d..71dd513b59 100644
--- a/database/rrdcontext.c
+++ b/database/rrdcontext.c
@@ -2377,6 +2377,11 @@ static inline int rrdcontext_to_json_callback(const char *id, void *value, void
}
int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, const char *context, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
+ if(!host->rrdctx) {
+ error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, host->hostname);
+ return HTTP_RESP_NOT_FOUND;
+ }
+
RRDCONTEXT_ACQUIRED *rca = (RRDCONTEXT_ACQUIRED *)dictionary_get_and_acquire_item((DICTIONARY *)host->rrdctx, context);
if(!rca) return HTTP_RESP_NOT_FOUND;
@@ -2412,6 +2417,11 @@ int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, R
}
int rrdcontexts_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
+ if(!host->rrdctx) {
+ error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, host->hostname);
+ return HTTP_RESP_NOT_FOUND;
+ }
+
char node_uuid[UUID_STR_LEN] = "";
if(host->node_id)