Merge pull request #2501 from dotcloud/2480-check_port-fix

check port is valid
This commit is contained in:
Guillaume J. Charmes 2013-11-04 11:23:55 -08:00
commit 261c2e23d3

View file

@ -225,6 +225,12 @@ func parsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding,
if containerPort == "" { if containerPort == "" {
return nil, nil, fmt.Errorf("No port specified: %s<empty>", rawPort) return nil, nil, fmt.Errorf("No port specified: %s<empty>", rawPort)
} }
if _, err := strconv.ParseUint(containerPort, 10, 16); err != nil {
return nil, nil, fmt.Errorf("Invalid containerPort: %s", containerPort)
}
if _, err := strconv.ParseUint(hostPort, 10, 16); hostPort != "" && err != nil {
return nil, nil, fmt.Errorf("Invalid hostPort: %s", hostPort)
}
port := NewPort(proto, containerPort) port := NewPort(proto, containerPort)
if _, exists := exposedPorts[port]; !exists { if _, exists := exposedPorts[port]; !exists {