Skip to content

Commit

Permalink
config: only set properties for plugins with CFL_VARIANT_STRING.
Browse files Browse the repository at this point in the history
Only set properties for plugins within arrays when the type is
of type variant string. This avoids memory access problems when
properties are set as lists.

Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Apr 2, 2024
1 parent c51e73a commit 4196714
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/flb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,40 +801,56 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
if (type == FLB_CF_CUSTOM) {
if (kv->val->type == CFL_VARIANT_STRING) {
ret = flb_custom_set_property(ins, kv->key, kv->val->data.as_string);
} else if (kv->val->type == CFL_VARIANT_ARRAY) {
}
else if (kv->val->type == CFL_VARIANT_ARRAY) {
for (i = 0; i < kv->val->data.as_array->entry_count; i++) {
val = kv->val->data.as_array->entries[i];
ret = flb_custom_set_property(ins, kv->key, val->data.as_string);

if (val->type == CFL_VARIANT_STRING) {
ret = flb_custom_set_property(ins, kv->key, val->data.as_string);
}
}
}
}
else if (type == FLB_CF_INPUT) {
if (kv->val->type == CFL_VARIANT_STRING) {
ret = flb_input_set_property(ins, kv->key, kv->val->data.as_string);
} else if (kv->val->type == CFL_VARIANT_ARRAY) {
}
else if (kv->val->type == CFL_VARIANT_ARRAY) {
for (i = 0; i < kv->val->data.as_array->entry_count; i++) {
val = kv->val->data.as_array->entries[i];
ret = flb_input_set_property(ins, kv->key, val->data.as_string);

if (val->type == CFL_VARIANT_STRING) {
ret = flb_input_set_property(ins, kv->key, val->data.as_string);
}
}
}
}
else if (type == FLB_CF_FILTER) {
if (kv->val->type == CFL_VARIANT_STRING) {
ret = flb_filter_set_property(ins, kv->key, kv->val->data.as_string);
} else if (kv->val->type == CFL_VARIANT_ARRAY) {
}
else if (kv->val->type == CFL_VARIANT_ARRAY) {
for (i = 0; i < kv->val->data.as_array->entry_count; i++) {
val = kv->val->data.as_array->entries[i];
ret = flb_filter_set_property(ins, kv->key, val->data.as_string);

if (val->type == CFL_VARIANT_STRING) {
ret = flb_filter_set_property(ins, kv->key, val->data.as_string);
}
}
}
}
else if (type == FLB_CF_OUTPUT) {
if (kv->val->type == CFL_VARIANT_STRING) {
ret = flb_output_set_property(ins, kv->key, kv->val->data.as_string);
} else if (kv->val->type == CFL_VARIANT_ARRAY) {
}
else if (kv->val->type == CFL_VARIANT_ARRAY) {
for (i = 0; i < kv->val->data.as_array->entry_count; i++) {
val = kv->val->data.as_array->entries[i];
ret = flb_output_set_property(ins, kv->key, val->data.as_string);

if (val->type == CFL_VARIANT_STRING) {
ret = flb_output_set_property(ins, kv->key, val->data.as_string);
}
}
}
}
Expand Down

0 comments on commit 4196714

Please sign in to comment.