From 8f1fd00d07e676b74d33c0c26a121a0bf654383e Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Mon, 21 Oct 2024 21:20:44 +0200 Subject: [PATCH] out_azure_blob: fixed missing parameter detection Signed-off-by: Leonardo Alminana --- plugins/out_azure_blob/azure_blob.c | 10 ++++++++++ plugins/out_azure_blob/azure_blob_conf.c | 5 +++++ plugins/out_azure_blob/azure_blob_db.c | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/plugins/out_azure_blob/azure_blob.c b/plugins/out_azure_blob/azure_blob.c index 1ef9be49552..98a1ff8807f 100644 --- a/plugins/out_azure_blob/azure_blob.c +++ b/plugins/out_azure_blob/azure_blob.c @@ -649,6 +649,12 @@ static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk struct flb_log_event_decoder log_decoder; struct flb_log_event log_event; + if (ctx->db == NULL) { + flb_plg_error(ctx->ins, "Cannot process blob because this operation requires a database."); + + return -1; + } + ret = flb_log_event_decoder_init(&log_decoder, (char *) event_chunk->data, event_chunk->size); @@ -724,6 +730,10 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context flb_sched_timer_cb_coro_return(); } + if (ctx->db == NULL) { + flb_sched_timer_cb_coro_return(); + } + info->active_upload = FLB_TRUE; /* diff --git a/plugins/out_azure_blob/azure_blob_conf.c b/plugins/out_azure_blob/azure_blob_conf.c index a66af75933a..d9c6ee68837 100644 --- a/plugins/out_azure_blob/azure_blob_conf.c +++ b/plugins/out_azure_blob/azure_blob_conf.c @@ -567,6 +567,11 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in return NULL; } + if (ctx->account_name == NULL) { + flb_plg_error(ctx->ins, "'account_name' has not been set"); + return NULL; + } + if (ctx->configuration_endpoint_url != NULL) { ret = flb_azure_blob_apply_remote_configuration(ctx); diff --git a/plugins/out_azure_blob/azure_blob_db.c b/plugins/out_azure_blob/azure_blob_db.c index fba43e74bbc..6951877ae01 100644 --- a/plugins/out_azure_blob/azure_blob_db.c +++ b/plugins/out_azure_blob/azure_blob_db.c @@ -251,6 +251,10 @@ struct flb_sqldb *azb_db_open(struct flb_azure_blob *ctx, char *db_path) int azb_db_close(struct flb_azure_blob *ctx) { + if (ctx->db == NULL) { + return 0; + } + /* finalize prepared statements */ sqlite3_finalize(ctx->stmt_insert_file); sqlite3_finalize(ctx->stmt_delete_file); @@ -272,6 +276,7 @@ int azb_db_close(struct flb_azure_blob *ctx) sqlite3_finalize(ctx->stmt_get_oldest_file_with_parts); pthread_mutex_destroy(&ctx->db_lock); + return flb_sqldb_close(ctx->db); }