upb: reject aligned MiniTable size overflow#26858
Open
heap-fixer wants to merge 3 commits intoprotocolbuffers:mainfrom
Open
upb: reject aligned MiniTable size overflow#26858heap-fixer wants to merge 3 commits intoprotocolbuffers:mainfrom
heap-fixer wants to merge 3 commits intoprotocolbuffers:mainfrom
Conversation
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.
This patch fixes a MiniTable size alignment overflow in
upb/mini_descriptor/decode.c.Previously, MiniTable construction checked the unaligned message layout size against
UINT16_MAX, stored it in the 16-bitupb_MiniTable::sizefield, and only then aligned it up tokUpb_Message_Align. For sizes nearUINT16_MAX, that alignment step could produce65536, which truncated to0when written back to the 16-bit size field.That could leave a MiniTable with:
size == 0and later cause
_upb_Message_New()/upb_Message_New()to allocate a zero-sized arena object for a non-empty message layout.This patch fixes the issue by:
size_tUINT16_MAXupb_MiniTable::sizeafter validationIt also adds a regression test covering the alignment-overflow boundary, so MiniTable construction now fails instead of producing a wrapped zero-sized layout.