fix: validate port range 1-65535 in parsePortValues (closes #25)

Add upper bound check (maxPort = 65535) to reject invalid port numbers.
Add comprehensive test cases for port validation.
This commit is contained in:
user
2026-02-15 21:34:50 -08:00
parent 97ee1e212f
commit 35ef6c8fea
2 changed files with 37 additions and 1 deletions

View File

@@ -1018,7 +1018,8 @@ func parsePortValues(hostPortStr, containerPortStr string) (int, int, bool) {
hostPort, hostErr := strconv.Atoi(hostPortStr)
containerPort, containerErr := strconv.Atoi(containerPortStr)
if hostErr != nil || containerErr != nil || hostPort <= 0 || containerPort <= 0 {
const maxPort = 65535
if hostErr != nil || containerErr != nil || hostPort <= 0 || containerPort <= 0 || hostPort > maxPort || containerPort > maxPort {
return 0, 0, false
}