Skip to content

Reject IPv4 components before compressed IPv6 groups - #3837

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
PHJ2000:fix-ipv6-dotted-quad-position
Oct 22, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
PHJ2000:fix-ipv6-dotted-quad-position

Conversation

@PHJ2000

@PHJ2000 PHJ2000 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

ParseUtil.parseIpv6AddressToBytes("1.2.3.4::") currently returns sixteen bytes, even though a dotted IPv4 component must occupy the final 32 bits of an IPv6 address (RFC 4291 section 2.2). The same problem accepts a dotted quad on both sides of ::.

Reject dotted quads in the portion before ::. The shared parser covers both native backends. Add regression cases for invalid positions and preserve valid compressed and uncompressed mixed addresses.

Validation on Linux, JDK 25:

  • The regression fails before the fix.
  • The common module's tests, forbidden-API check and Javadoc generation pass: 1,918 successful tests, 29 skipped, 2 aborted.
  • Applied Spotless and sortpom.
  • The prescribed full gate was attempted. Checkstyle reports an existing missing test package-info in TestFileUtil; the full aggregate-coverage run also reports three hardware comparison failures (diskStores, processorIdentifier, processorFrequencies). All four failures reproduce on an unmodified checkout. Native implementations on other operating systems were not run locally.

Reference: https://www.rfc-editor.org/rfc/rfc4291.html#section-2.2

Summary by CodeRabbit

  • Bug Fixes
    • IPv6 addresses with an embedded IPv4 component in an invalid position are now rejected. Valid IPv6 addresses ending in an IPv4 component continue to parse correctly.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76e2563a-fc98-4a9c-8ce9-401873a1dee8
📥 Commits

Reviewing files that changed from the base of the PR and between 6bc9a59 and 6a5bff0.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📜 Recent review details
🧰 Additional context used
📚 Code guidelines: 2
AGENTS.md — auto-discovered
.github/CONTRIBUTING.md — auto-discovered
📓 Path-based instructions: 5
Source excerpt: **Banned APIs** (`config/forbidden-apis.txt` and friends, enforced by `forbiddenapis:check`): `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any `System.load`/`loadLibrary`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
Applicability reference: AGENTS.md: # AGENTS.md Instructions for AI coding agents working in the OSHI repository.

📄 CodeRabbit inference engine (.github/CONTRIBUTING.md)

Files:

  • CHANGELOG.md
Source excerpt: Add a `CHANGELOG.md` entry under *Next Release* **only for user-visible changes**.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • CHANGELOG.md
Source excerpt: Tests run under `de.sormuras.junit:junit-platform-maven-plugin`, **not** Surefire.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
Source excerpt: **Javadoc.**

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/java/oshi/util/ParseUtil.java
  • oshi-common/src/test/java/oshi/util/ParseUtilTest.java
🔇 Additional comments: 3
oshi-common/src/main/java/oshi/util/ParseUtil.java: 1

1433-1436: LGTM!

oshi-common/src/test/java/oshi/util/ParseUtilTest.java: 1

1241-1255: LGTM!

CHANGELOG.md: 1

3-3: LGTM!

📝 Walkthrough

The IPv6 parser now rejects addresses that place a dotted IPv4 component before compressed zero groups. Tests verify rejected positions and valid addresses with the dotted quad in the final 32 bits. The changelog records the change.

Changes: IPv6 address parsing

Layer / File(s) Summary
Validate dotted-quad position
oshi-common/src/main/java/oshi/util/ParseUtil.java, oshi-common/src/test/java/oshi/util/ParseUtilTest.java, CHANGELOG.md
The parser rejects a dotted quad before ::. Tests check invalid and valid dotted-quad positions. The changelog records the change.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: dbwiddis

Merge Risk: ⚪ Minimal · up to 6a5bf

No concrete merge-blocking risk is established by the reviewed change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: rejecting IPv4 components before compressed IPv6 groups.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the address line,
And spots the quad before the sign.
Compressed zeros? That quad must wait,
The final bits are where it’s placed.
The parser hops; the tests shine bright.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.03%. Comparing base (ba38793) to head (6a5bff0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3837      +/-   ##
============================================
- Coverage     81.08%   81.03%   -0.06%     
  Complexity      776      776              
============================================
  Files           726      726              
  Lines         26323    26325       +2     
  Branches       4470     4471       +1     
============================================
- Hits          21344    21332      -12     
- Misses         2768     2783      +15     
+ Partials       2211     2210       -1     
Flag Coverage Δ
freebsd 37.85% <100.00%> (+<0.01%) ⬆️
linux 41.80% <100.00%> (+<0.01%) ⬆️
macos 42.72% <100.00%> (-0.04%) ⬇️
netbsd 37.14% <100.00%> (-0.01%) ⬇️
openbsd 37.69% <100.00%> (+0.01%) ⬆️
solaris 38.96% <100.00%> (-0.03%) ⬇️
windows 49.10% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@dbwiddis

Copy link
Copy Markdown
Member

Hey @PHJ2000 thanks for this PR! Looks great, merging as-is. Let me know if you need a new release cut, I usually wait at least a week between releases.

@dbwiddis
dbwiddis merged commit 5d4da5b into oshi:master Oct 22, 2026
32 of 33 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