Browse code

check port is valid

Victor Vieux authored on 2013/11/01 10:33:42
Showing 1 changed files
... ...
@@ -225,6 +225,12 @@ func parsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding,
225 225
 		if containerPort == "" {
226 226
 			return nil, nil, fmt.Errorf("No port specified: %s<empty>", rawPort)
227 227
 		}
228
+		if _, err := strconv.ParseUint(containerPort, 10, 16); err != nil {
229
+			return nil, nil, fmt.Errorf("Invalid containerPort: %s", containerPort)
230
+		}
231
+		if _, err := strconv.ParseUint(hostPort, 10, 16); hostPort != "" && err != nil {
232
+			return nil, nil, fmt.Errorf("Invalid hostPort: %s", hostPort)
233
+		}
228 234
 
229 235
 		port := NewPort(proto, containerPort)
230 236
 		if _, exists := exposedPorts[port]; !exists {