Fix crash when logging NULL chars. #1093
Merged
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.
When log NULL char, the server crashed on panic on redismodule-rs when trying to convert the
&str
toCString
:https://github.com/RedisLabsModules/redismodule-rs/blob/bf2b3a6a04b795ad1d58d5252ae22d25430c3349/src/logging.rs#L55
When we create our logs we can be sure we do not have embedded NULLs inside the log message, but when the log message comes from user script we can not be sure. To solve it we escape the string using
escape_default
which will escape all chars according to the following rules:\t
.\r
.\n
.\'
.\"
.\\
.0x20
..0x7e
inclusive is not escaped.