summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-21 21:00:16 -0400
committerGitHub <noreply@github.com>2020-10-21 21:00:16 -0400
commit2cd2359a6d9ba4135495dc9be616bb1edebb170d (patch)
tree97fc6e19db7e79683b242958b038c528eb451533 /libpod
parent2bd920b00540280696d19dc95ab6e562aebd6b7d (diff)
parent33366a2cda518fafed0e72cf6e53b55abfa3c5e5 (diff)
downloadpodman-2cd2359a6d9ba4135495dc9be616bb1edebb170d.tar.gz
podman-2cd2359a6d9ba4135495dc9be616bb1edebb170d.tar.bz2
podman-2cd2359a6d9ba4135495dc9be616bb1edebb170d.zip
Merge pull request #7772 from TomSweeneyRedHat/dev/tsweeney/splitn
Convert Split() calls with an equal sign to SplitN()
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/filters.go4
-rw-r--r--libpod/image/search.go2
-rw-r--r--libpod/networking_linux.go6
3 files changed, 7 insertions, 5 deletions
diff --git a/libpod/image/filters.go b/libpod/image/filters.go
index db647954f..4aff0a7b5 100644
--- a/libpod/image/filters.go
+++ b/libpod/image/filters.go
@@ -82,7 +82,7 @@ func LabelFilter(ctx context.Context, labelfilter string) ResultFilter {
// We need to handle both label=key and label=key=value
return func(i *Image) bool {
var value string
- splitFilter := strings.Split(labelfilter, "=")
+ splitFilter := strings.SplitN(labelfilter, "=", 2)
key := splitFilter[0]
if len(splitFilter) > 1 {
value = splitFilter[1]
@@ -157,7 +157,7 @@ func (ir *Runtime) createFilterFuncs(filters []string, img *Image) ([]ResultFilt
var filterFuncs []ResultFilter
ctx := context.Background()
for _, filter := range filters {
- splitFilter := strings.Split(filter, "=")
+ splitFilter := strings.SplitN(filter, "=", 2)
if len(splitFilter) < 2 {
return nil, errors.Errorf("invalid filter syntax %s", filter)
}
diff --git a/libpod/image/search.go b/libpod/image/search.go
index 5f5845989..b9acf4a20 100644
--- a/libpod/image/search.go
+++ b/libpod/image/search.go
@@ -263,7 +263,7 @@ func searchRepositoryTags(registry, term string, sc *types.SystemContext, option
func ParseSearchFilter(filter []string) (*SearchFilter, error) {
sFilter := new(SearchFilter)
for _, f := range filter {
- arr := strings.Split(f, "=")
+ arr := strings.SplitN(f, "=", 2)
switch arr[0] {
case "stars":
if len(arr) < 2 {
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index df0ff6c32..9ff6e40b7 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -254,9 +254,11 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error {
if ctr.config.NetworkOptions != nil {
slirpOptions := ctr.config.NetworkOptions["slirp4netns"]
for _, o := range slirpOptions {
- parts := strings.Split(o, "=")
+ parts := strings.SplitN(o, "=", 2)
+ if len(parts) < 2 {
+ return errors.Errorf("unknown option for slirp4netns: %q", o)
+ }
option, value := parts[0], parts[1]
-
switch option {
case "cidr":
ipv4, _, err := net.ParseCIDR(value)