Skip to content

Commit

Permalink
grep: use flb_sds_snprintf to construct rule
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 committed Feb 2, 2024
1 parent 011a86e commit 1e303c3
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/flb_grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,10 @@ int flb_grep_set_rule_str(struct flb_grep *grep_ctx, enum flb_grep_rule_type typ
flb_utils_split_free(split);
return -1;
}
ret = flb_sds_cat_safe(&rule->field, "$", 1);
if (ret != 0) {
flb_error("flb_sds_cat_safe failed");
delete_rule(rule);
flb_utils_split_free(split);
return -1;
}

ret = flb_sds_cat_safe(&rule->field, sentry->value, sentry->len);
if (ret != 0) {
flb_error("flb_sds_cat_safe failed");
ret = flb_sds_snprintf(&rule->field, flb_sds_alloc(rule->field),
"$%.*s", (int)sentry->len, sentry->value);
if (ret < 0 || ret >= sentry->len + 2) {
flb_error("flb_sds_snprintf failed");
delete_rule(rule);
flb_utils_split_free(split);
return -1;
Expand Down

0 comments on commit 1e303c3

Please sign in to comment.