Repository navigation
Fix syslog server panic on RFC5424 nil timestamp - #614
Merged
Merged
Conversation
RFC5424 §6.2.3 allows the TIMESTAMP field to be the NILVALUE "-", in which case the parser leaves msg.Timestamp nil. convertToEnvelope dereferenced it unconditionally, so a single such message panicked the syslog server. - Fall back to the time of receipt when the timestamp is nil. - Return early in parseListener when the result is not an RFC5424 message; previously it logged the error and fell through. - Add a test that a nil-timestamp message is accepted and stamped with the receive time.
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
RFC5424 §6.2.3 allows the TIMESTAMP field to be the NILVALUE "-", in which case the parser leaves
msg.Timestampnil.convertToEnvelopedereferenced it unconditionally, so a single such message panicked the syslog server.nil.parseListenerwhen the result is not an RFC5424 message; previously it logged the error and fell through.Checked for other unchecked dereferencing scenarios. Only other possibility was with
*msg.Prioritybut confirmed in the vendored code it could only be nil if configured with:rfc5424.WithOptionalPriority()ingithub.com/leodido/go-syslog/v4. It is not configured as such in this codebase.Type of change
Testing performed?
Checklist:
mainbranch, or relevant version branchIf you have any questions, or want to get attention for a PR or issue please reach out on the #logging-and-metrics channel in the cloudfoundry slack