summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/containers.go
diff options
context:
space:
mode:
authorzhangguanzhang <zhangguanzhang@qq.com>2020-06-08 19:24:44 +0800
committerzhangguanzhang <zhangguanzhang@qq.com>2020-06-10 00:03:04 +0800
commit3218736cff4b718b8fe855759687cb66f19d6e1e (patch)
treef4af8846f85a514c4ae1c1b5c545298967d068e4 /pkg/api/handlers/compat/containers.go
parent1fcb6788a5d7471a7ca6215a40e36e21812a0f6e (diff)
downloadpodman-3218736cff4b718b8fe855759687cb66f19d6e1e.tar.gz
podman-3218736cff4b718b8fe855759687cb66f19d6e1e.tar.bz2
podman-3218736cff4b718b8fe855759687cb66f19d6e1e.zip
fix api fails with 'strconv.ParseUint: parsing "tcp": invalid syntax'
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
Diffstat (limited to 'pkg/api/handlers/compat/containers.go')
-rw-r--r--pkg/api/handlers/compat/containers.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index cea4bd0f6..1fd068ba6 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -465,8 +465,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
ports := make(nat.PortSet)
for p := range inspect.HostConfig.PortBindings {
- splitp := strings.Split(p, "/")
- port, err := nat.NewPort(splitp[0], splitp[1])
+ splitp := strings.SplitN(p, "/", 2)
+ if len(splitp) != 2 {
+ return nil, errors.Errorf("PORT/PROTOCOL Format required for %q", p)
+ }
+ port, err := nat.NewPort(splitp[1], splitp[0])
if err != nil {
return nil, err
}