mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
check port is valid
This commit is contained in:
parent
e3c49843d7
commit
7f07ae9e42
1 changed files with 6 additions and 0 deletions
6
utils.go
6
utils.go
|
@ -225,6 +225,12 @@ func parsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding,
|
|||
if containerPort == "" {
|
||||
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)
|
||||
if _, exists := exposedPorts[port]; !exists {
|
||||
|
|
Loading…
Add table
Reference in a new issue