-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conditionals: fix handling of empty string values #10172
base: master
Are you sure you want to change the base?
Conversation
Please don't remove review requests in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change all the pointer validations to explicitly compare against NULL
(not just the ones I marked).
@@ -66,8 +66,14 @@ static struct flb_condition_rule *rule_create(const char *field, | |||
switch (op) { | |||
case FLB_RULE_OP_EQ: | |||
case FLB_RULE_OP_NEQ: | |||
/* Allow empty string values for equality comparisons */ | |||
if (!value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please modify this to explicitly compare with NULL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, wouldn't this be covered by the conditional in line 62? (which should be modified to explicitly compare the pointer values with NULL
)
case FLB_RULE_OP_REGEX: | ||
case FLB_RULE_OP_NOT_REGEX: | ||
/* Regex patterns must not be empty */ | ||
if (!value || !((char *)value)[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please modify this to explicitly compare with NULL
.
Please refactor the second part of the term to make it clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, since I don't see a loop or goto I don't understand why do we need to check that value
is not NULL
here as well, could you please clarify this?
|
||
/* Using cfl_variant_create_from_string instead of a non-existent cfl_variant_set_string */ | ||
variant = cfl_variant_create_from_string((char *)value); | ||
if (!variant) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are not doing anything (ie. reporting) if cfl_variant_create_from_string
returns NULL
why do you have this code? returning variant
would be the same.
Summary
Fixes #10168