fix(syslog): return early when logger init fails - #13970
Open
bhuvan-somisetty wants to merge 1 commit into
Open
bhuvan-somisetty wants to merge 1 commit into
bhuvan-somisetty wants to merge 1 commit into
Conversation
send_syslog_data detected a failed logger init but fell through to logger:log(log_message) on the next line, indexing a nil value and crashing the log phase instead of returning the already built error. Fixes apache#13969
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
send_syslog_data() in apisix/plugins/syslog/init.lua fetches the logger instance from the lrucache and correctly checks whether it failed:
if not logger then
res = false
err_msg = "failed when initiating the sys logger processor".. err
end
When logger_socket.new(...) fails, for example due to a bad host or port or a socket error, logger is nil and this branch correctly builds an error message, but it never returns. Execution falls through to the very next line, logger:log(log_message), which indexes a nil value. This throws an uncaught Lua runtime error inside the log phase batch processor callback instead of returning the already built false, err_msg back to the caller, the same way the function already does for the logger:log() failure case right below it.
This PR adds the missing return so a failed logger init is reported as a clean batch processor error instead of crashing the log phase.
Which issue(s) this PR fixes:
Fixes #13969
Checklist