Repository navigation
fix: reject empty ports in tcp4 address validation - #1659
Open
sergioperezcheco wants to merge 1 commit into
Open
sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
Preserve explicit port zero and the existing address resolution checks. Co-Authored-By: OpenAI GPT-6.1-Sol <noreply@openai.com> Signed-off-by: sergioperezcheco <checo520@outlook.com>
Contributor
|
According to the documentation, Lines 1302 to 1306 in f3194ca What is the TCP (or TCP4) address? This is what the "address" refers to. Address does not include port. Am I wrong? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reject an empty TCP4 port
tcp4_addraccepts127.0.0.1:becausenet.ResolveTCPAddrtreats an empty port as zero. Check the host/port split before resolution and reject an empty port, as discussed in #1003. Explicit:0remains valid, and the existing IPv4 and port-range checks are preserved.The regression exercises both
Validate.VarandValidate.Structfor empty, missing, zero, normal, maximum, overflowing and negative ports, plus an invalid IPv4 address. The original implementation fails the two empty-port cases; the change passes all nine cases. Native Go 1.26.4 validation passedgo test -race -cover ./...,go vet ./..., and golangci-lint v2.13.1 with zero issues. Other OS/Go-version matrix jobs have not been run locally.Fixes #1003.
AI-assisted contribution: investigation, implementation, tests and this description were produced with OpenAI GPT-6.1-Sol through Hermes; the commit includes the required model attribution.