Skip to content

Commit a3b53a2

Browse files
CopilotByron
andcommitted
Add port 0 validation for IPv6 addresses
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
1 parent 4d61b89 commit a3b53a2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

gix-url/src/simple_url.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ impl<'a> ParsedUrl<'a> {
121121
let port = port_str
122122
.parse::<u16>()
123123
.map_err(|_| ParseError::InvalidPort)?;
124+
// Validate port is in valid range (1-65535, port 0 is invalid)
125+
if port == 0 {
126+
return Err(ParseError::InvalidPort);
127+
}
124128
return Ok((host, Some(port)));
125129
} else {
126130
return Err(ParseError::InvalidDomainCharacter);

0 commit comments

Comments
 (0)