Skip to content

fix(socks5): correctly expand IPv6 '::' compressed notation#5046

Open
deepview-autofix wants to merge 1 commit intonodejs:mainfrom
deepview-autofix:deepview/f2f171dfb9
Open

fix(socks5): correctly expand IPv6 '::' compressed notation#5046
deepview-autofix wants to merge 1 commit intonodejs:mainfrom
deepview-autofix:deepview/f2f171dfb9

Conversation

@deepview-autofix
Copy link
Copy Markdown
Contributor

The previous implementation used doubleColonIndex / 3 to map the character offset of '::' to a parts-array index, which only works when every group before '::' is exactly three characters wide. For typical addresses like 2001:db8::1 or fe80::1 the zero-fill gap was never applied, producing a wrong 16-byte buffer and, in a SOCKS5 proxy context, connections to unintended destinations.

Rewrite parseIPv6 to split around '::' and write the trailing groups at their correct offsets from the end of the buffer.

The previous implementation used `doubleColonIndex / 3` to map the
character offset of '::' to a parts-array index, which only works when
every group before '::' is exactly three characters wide. For typical
addresses like `2001:db8::1` or `fe80::1` the zero-fill gap was never
applied, producing a wrong 16-byte buffer and, in a SOCKS5 proxy
context, connections to unintended destinations.

Rewrite parseIPv6 to split around '::' and write the trailing groups
at their correct offsets from the end of the buffer.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com>
Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.03%. Comparing base (d2e8178) to head (e767a13).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5046      +/-   ##
==========================================
- Coverage   93.03%   93.03%   -0.01%     
==========================================
  Files         110      110              
  Lines       35793    35788       -5     
==========================================
- Hits        33299    33294       -5     
  Misses       2494     2494              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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