Avoid corruption when deserializing booleans#22152
Merged
jasontedor merged 1 commit intoelastic:masterfrom Dec 14, 2016
Merged
Conversation
nik9000
approved these changes
Dec 13, 2016
Member
nik9000
left a comment
There was a problem hiding this comment.
Sounds like a good idea to me.
jaymode
approved these changes
Dec 14, 2016
Today we write 0x00 or 0x01 for false or true when serializing a boolean (and 0x02 for null when serializing an optional boolean) but we deserialize any non-zero byte to true (except when deserializing an optional boolean in which case we deserialize 0x02 to null, 0x01 to true, and any other non-zero byte to false). This too easily allows corruption into the stream. Instead, we should mark the stream as corrupted and stop deserializing. This catches when we try to deserialize something as a boolean that is not a boolean.
77f7be9 to
a378b5a
Compare
jasontedor
added a commit
that referenced
this pull request
Dec 14, 2016
Today we write 0x00 or 0x01 for false or true when serializing a boolean (and 0x02 for null when serializing an optional boolean) but we deserialize any non-zero byte to true (except when deserializing an optional boolean in which case we deserialize 0x02 to null, 0x01 to true, and any other non-zero byte to false). This too easily allows corruption into the stream. Instead, we should mark the stream as corrupted and stop deserializing. This catches when we try to deserialize something as a boolean that is not a boolean. Relates #22152
Member
Author
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.
Today we write 0x00 or 0x01 for false or true when serializing a boolean
(and 0x02 for null when serializing an optional boolean) but we
deserialize any non-zero byte to true (except when deserializing an
optional boolean in which case we deserialize 0x02 to null, 0x01 to
true, and any other non-zero byte to false). This too easily allows
corruption into the stream. Instead, we should mark the stream as
corrupted and stop deserializing. This catches when we try to
deserialize something as a boolean that is not a boolean.