Skip to content

Commit 1ffa521

Browse files
committed
filter_log_to_metrics: Process validations for range tightly
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 5a7a6e6 commit 1ffa521

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plugins/filter_log_to_metrics/log_to_metrics.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ static int set_labels(struct log_to_metrics_ctx *ctx,
434434
mk_list_foreach(head, &f_ins->properties) {
435435
kv = mk_list_entry(head, struct flb_kv, _head);
436436

437-
if (counter > ctx->label_counter) {
438-
flb_plg_error(ctx->ins, "internal label counter overflow");
439-
return -1;
440-
}
441-
442437
if (strcasecmp(kv->key, "label_field") == 0) {
438+
if (counter >= ctx->label_counter) {
439+
flb_plg_error(ctx->ins, "internal label counter overflow");
440+
return -1;
441+
}
442+
443443
/* name and accessor are the same string */
444444
ctx->label_keys[counter] = flb_strdup(kv->val);
445445
if (!ctx->label_keys[counter]) {
@@ -454,6 +454,10 @@ static int set_labels(struct log_to_metrics_ctx *ctx,
454454
counter++;
455455
}
456456
else if (strcasecmp(kv->key, "add_label") == 0) {
457+
if (counter >= ctx->label_counter) {
458+
flb_plg_error(ctx->ins, "internal label counter overflow");
459+
return -1;
460+
}
457461
split = flb_utils_split(kv->val, ' ', 1);
458462
if (mk_list_size(split) != 2) {
459463
flb_plg_error(ctx->ins, "invalid label, expected name and key");

0 commit comments

Comments
 (0)