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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user