Skip to content

Commit 8f1fd00

Browse files
Leonardo Alminanaedsiper
authored andcommitted
out_azure_blob: fixed missing parameter detection
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent 30eb89e commit 8f1fd00

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

plugins/out_azure_blob/azure_blob.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,12 @@ static int process_blob_chunk(struct flb_azure_blob *ctx, struct flb_event_chunk
649649
struct flb_log_event_decoder log_decoder;
650650
struct flb_log_event log_event;
651651

652+
if (ctx->db == NULL) {
653+
flb_plg_error(ctx->ins, "Cannot process blob because this operation requires a database.");
654+
655+
return -1;
656+
}
657+
652658
ret = flb_log_event_decoder_init(&log_decoder,
653659
(char *) event_chunk->data,
654660
event_chunk->size);
@@ -724,6 +730,10 @@ static void cb_azb_blob_file_upload(struct flb_config *config, void *out_context
724730
flb_sched_timer_cb_coro_return();
725731
}
726732

733+
if (ctx->db == NULL) {
734+
flb_sched_timer_cb_coro_return();
735+
}
736+
727737
info->active_upload = FLB_TRUE;
728738

729739
/*

plugins/out_azure_blob/azure_blob_conf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ struct flb_azure_blob *flb_azure_blob_conf_create(struct flb_output_instance *in
567567
return NULL;
568568
}
569569

570+
if (ctx->account_name == NULL) {
571+
flb_plg_error(ctx->ins, "'account_name' has not been set");
572+
return NULL;
573+
}
574+
570575
if (ctx->configuration_endpoint_url != NULL) {
571576
ret = flb_azure_blob_apply_remote_configuration(ctx);
572577

plugins/out_azure_blob/azure_blob_db.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ struct flb_sqldb *azb_db_open(struct flb_azure_blob *ctx, char *db_path)
251251

252252
int azb_db_close(struct flb_azure_blob *ctx)
253253
{
254+
if (ctx->db == NULL) {
255+
return 0;
256+
}
257+
254258
/* finalize prepared statements */
255259
sqlite3_finalize(ctx->stmt_insert_file);
256260
sqlite3_finalize(ctx->stmt_delete_file);
@@ -272,6 +276,7 @@ int azb_db_close(struct flb_azure_blob *ctx)
272276
sqlite3_finalize(ctx->stmt_get_oldest_file_with_parts);
273277

274278
pthread_mutex_destroy(&ctx->db_lock);
279+
275280
return flb_sqldb_close(ctx->db);
276281
}
277282

0 commit comments

Comments
 (0)