-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
http_server: metrics: add null-dereference guards #7627
base: master
Are you sure you want to change the base?
http_server: metrics: add null-dereference guards #7627
Conversation
`flb_sds_cat` can fail and return NULL, this should be checked to avoid NULL dereferences. Signed-off-by: David Korczynski <[email protected]>
src/http_server/api/v1/metrics.c
Outdated
@@ -397,15 +397,45 @@ void cb_metrics_prometheus(mk_request_t *request, void *data) | |||
} | |||
|
|||
sds_metric = flb_sds_cat(sds_metric, "fluentbit_", 10); |
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.
Could you replace this with a single call to flb_sds_printf
or at least use flb_sds_cat_safe
? Otherwise these will exchange a possible NULL
deref for a memory leak.
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.
I replaced it with flb_sds_cat_safe
30558b9
to
c19a58f
Compare
Signed-off-by: David Korczynski <[email protected]>
c19a58f
to
d665868
Compare
@@ -396,16 +396,36 @@ void cb_metrics_prometheus(mk_request_t *request, void *data) | |||
goto error; | |||
} | |||
|
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.
Could you please just use flb_sds_printf
once here?
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
flb_sds_cat
can fail and return NULL, this should be checked to avoid NULL dereferences.Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.