Skip to content

Add bounds checking for AS path segment types#1

Open
IlianaXn wants to merge 1 commit into
gatech-masterfrom
fix-invalid-as-path-segment-bound-check
Open

Add bounds checking for AS path segment types#1
IlianaXn wants to merge 1 commit into
gatech-masterfrom
fix-invalid-as-path-segment-bound-check

Conversation

@IlianaXn

Copy link
Copy Markdown
Collaborator

Add the same check in append_segments_all as in the append_segments:

// ensure we're not going to wander off the end of as_path_types array
if (seg->type < PARSEBGP_BGP_UPDATE_AS_PATH_SEG_AS_SET ||
seg->type > PARSEBGP_BGP_UPDATE_AS_PATH_SEG_CONFED_SET) {
bgpstream_log(BGPSTREAM_LOG_ERR, "Unknown AS Path segment type %d",
seg->type);
return -1;
}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds defensive bounds checking in append_segments_all to match the existing validation already present in append_segments, preventing out-of-bounds access into the as_path_types lookup table when encountering unexpected AS_PATH segment types.

Changes:

  • Add validation of seg->type range in append_segments_all before indexing as_path_types.
  • Log an error and return -1 when an unknown AS path segment type is encountered.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants