Skip to content

fix: panic on full-width IP-SUFFIX rules#2975

Merged
wwqgtxx merged 1 commit into
MetaCubeX:Alphafrom
AaronChen0:ipsuffix
Jul 15, 2026
Merged

fix: panic on full-width IP-SUFFIX rules#2975
wwqgtxx merged 1 commit into
MetaCubeX:Alphafrom
AaronChen0:ipsuffix

Conversation

@AaronChen0

Copy link
Copy Markdown

IPSuffix.Match panics with index out of range [-1] when a rule uses a full-byte suffix such as IP-Suffix,1.2.3.4/32 and a connection's address matches that suffix exactly.

When bits%8 == 0, the full-byte loop already validated the entire suffix, so the sub-byte check is unnecessary (and the << 8 shift would be a no-op anyway).

To reproduce the panic:

  1. Add - IP-SUFFIX,1.1.1.1/32,DIRECT to your first rule.
  2. Run curl 1.1.1.1.

@wwqgtxx

wwqgtxx commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

It might look better to place the conditions on a single line, joined by &&.

@AaronChen0

Copy link
Copy Markdown
Author

Sure.

@wwqgtxx

wwqgtxx commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Your current submission contains compilation errors; please revise it.

@AaronChen0

AaronChen0 commented Jul 15, 2026

Copy link
Copy Markdown
Author

Fixed.

@AaronChen0

Copy link
Copy Markdown
Author

The 1 failed test on windows seems unrelated to this pull request.

@wwqgtxx

wwqgtxx commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Don't worry, we will merge them later when we have time.

@wwqgtxx
wwqgtxx merged commit c079b0c into MetaCubeX:Alpha Jul 15, 2026
134 of 135 checks passed
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