Skip to content

Conversation

@zbalkan
Copy link

@zbalkan zbalkan commented Jan 29, 2026

Solves #41:

When one ore more octets are missing the Span<byte> buffer = stackalloc byte[4]; line fills it with zeroes, therefore covers the error.

When one or more octets are extra, for (int i = 0, j = parts.Length - 3; (i < 4) && (j > -1); i++, j--) loop covers as it ignores the extras.

I added an explicit guard clause for IPv4 addresses.

Copilot AI review requested due to automatic review settings January 29, 2026 17:41
Copy link

Copilot AI left a comment

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 fixes a bug in the TryParseReverseDomain method where invalid IPv4 reverse DNS domains were incorrectly accepted. The issue occurred because missing octets were implicitly filled with zeros due to stackalloc initialization, and extra octets were silently ignored by the loop bounds.

Changes:

  • Added explicit validation to ensure IPv4 reverse DNS domains have exactly 6 parts (4 octets + "in-addr" + "arpa")
  • Added a clear comment explaining the expected format

💡 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.

1 participant