From 3218736cff4b718b8fe855759687cb66f19d6e1e Mon Sep 17 00:00:00 2001 From: zhangguanzhang Date: Mon, 8 Jun 2020 19:24:44 +0800 Subject: fix api fails with 'strconv.ParseUint: parsing "tcp": invalid syntax' Signed-off-by: zhangguanzhang --- pkg/api/handlers/compat/containers.go | 7 +++++-- 1 file 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 } -- cgit v1.2.3-54-g00ecf