in_forward: fix init error cleanup and parser state handling#11442
in_forward: fix init error cleanup and parser state handling#11442
Conversation
- Reset per-message option state in forward parser to avoid stale options reuse. - Fix HELO handshake path to return error immediately on send failure. - Add NULL-check for security.users split parsing. - Use fw_config_destroy() on init failures to cleanly release allocated resources. - Align options index types/sentinels (chunk_id/metadata_id) to int for safer comparisons. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
📝 WalkthroughWalkthroughThis PR improves error handling and resource cleanup in the in_forward plugin. It adds validation for user configuration parsing, centralizes cleanup via a dedicated destruction function, and adjusts function signatures for consistency in type handling. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
plugins/in_forward/fw.c (1)
210-214:⚠️ Potential issue | 🟡 MinorPre-existing:
flb_mallocfailure leaks previously added users.If
flb_mallocfails here,return -1is reached without callingdelete_users(ctx). Any users already linked toctx->usersin prior loop iterations will leak, sincefw_config_destroy(called by the caller) does not clean up the users list.Proposed fix
user = flb_malloc(sizeof(struct flb_in_fw_user)); if (!user) { flb_errno(); + delete_users(ctx); return -1; }
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.
Summary by CodeRabbit