summaryrefslogtreecommitdiff
path: root/cmd/podman/network_create.go
diff options
context:
space:
mode:
authorMrigank Krishan <mrigankkrishan@gmail.com>2019-10-04 02:00:29 +0530
committerMrigank Krishan <mrigankkrishan@gmail.com>2019-10-04 02:34:01 +0530
commitc5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba (patch)
tree22b35a2055f803e811eb12666460f7627889b53a /cmd/podman/network_create.go
parent86c8650c2328a4a611e614c7220627feae4d4eae (diff)
downloadpodman-c5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba.tar.gz
podman-c5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba.tar.bz2
podman-c5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba.zip
podman network create: validate user input
Disallow invalid/confusing names such as '../bar' or 'foo ' Closes #4184 Signed-off-by: Mrigank Krishan <mrigankkrishan@gmail.com>
Diffstat (limited to 'cmd/podman/network_create.go')
-rw-r--r--cmd/podman/network_create.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/podman/network_create.go b/cmd/podman/network_create.go
index 378a92568..11f13faad 100644
--- a/cmd/podman/network_create.go
+++ b/cmd/podman/network_create.go
@@ -4,11 +4,12 @@ package main
import (
"fmt"
- "github.com/containers/libpod/pkg/network"
"net"
"github.com/containers/libpod/cmd/podman/cliconfig"
+ "github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/network"
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -58,6 +59,9 @@ func networkcreateCmd(c *cliconfig.NetworkCreateValues) error {
if len(c.InputArgs) > 1 {
return errors.Errorf("only one network can be created at a time")
}
+ if len(c.InputArgs) > 0 && !libpod.NameRegex.MatchString(c.InputArgs[0]) {
+ return libpod.RegexError
+ }
runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
if err != nil {
return err