print-ospf: guard RI LSA TLV length before subtraction#1441
Open
TristanInSec wants to merge 1 commit into
Open
print-ospf: guard RI LSA TLV length before subtraction#1441TristanInSec wants to merge 1 commit into
TristanInSec wants to merge 1 commit into
Conversation
… TLVs The RI LSA parser passes tlv_length - 4 to ospf_print_ri_lsa_sid_label_range_tlv() without first checking that tlv_length >= 4. When tlv_length is 0-3, the unsigned subtraction wraps to a large value, causing the called function's while loop to read past the TLV boundary. Add a minimum length check before the subtraction, consistent with other RI LSA TLV handlers that already guard their subtractions (e.g., lines 818 and 847 check tlv_length > 12). Signed-off-by: Tristan <tristan@talencesecurity.com>
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.
The RI LSA TLV dispatch passes
tlv_length - 4toospf_print_ri_lsa_sid_label_range_tlv()for TLV types 9 (SID/LabelRange) and 14 (SR Local Block) without checking
tlv_length >= 4.When
tlv_lengthis 0–3, the unsigned subtraction wraps to a largevalue, causing the callee's
while (tlv_length != 0)loop to readpast the TLV boundary into adjacent packet data.
The fix adds a
tlv_length < 4guard that prints a bogus-lengthdiagnostic and returns, consistent with other TLV handlers in the
same function (e.g. lines 818/847).
Found by manual audit of commit 9ec6904.