From c130edb90bd7e884af7f1e915c14c13f1e3da408 Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 6 Jun 2021 18:43:14 +0900 Subject: [PATCH] filter_rewrite_tag: abort when infinite loop setting Some match rules causes infinite loop. This fix to prevent these settings. e.g. 'Match *' , 'Match ****' Signed-off-by: Takahiro Yamashita --- plugins/filter_rewrite_tag/rewrite_tag.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/filter_rewrite_tag/rewrite_tag.c b/plugins/filter_rewrite_tag/rewrite_tag.c index 98eb76b6cbe..0e3c22902da 100644 --- a/plugins/filter_rewrite_tag/rewrite_tag.c +++ b/plugins/filter_rewrite_tag/rewrite_tag.c @@ -186,6 +186,20 @@ static int process_config(struct flb_rewrite_tag *ctx) return 0; } +static int is_wildcard(char* match) +{ + size_t len = strlen(match); + size_t i; + + /* '***' should be ignored. So we check every char. */ + for (i=0; imatch)) { + flb_plg_error(ins, "'Match' causes infinite loop. abort."); + flb_free(ctx); + return -1; + } ctx->ins = ins; ctx->config = config; mk_list_init(&ctx->rules);