summaryrefslogtreecommitdiff
path: root/cmd/podman/search.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-04-03 13:51:40 -0700
committerGitHub <noreply@github.com>2019-04-03 13:51:40 -0700
commit7a2bca54f0194d7a4c5362e8e2a969ce54a367ba (patch)
tree5879ec88dce1b8132182e74909867d5196f2c415 /cmd/podman/search.go
parent42757c18553bb2e6865efed4c912e3361012c49c (diff)
parentc6255537d9b65326a3bdd1856f700425ecb71367 (diff)
downloadpodman-7a2bca54f0194d7a4c5362e8e2a969ce54a367ba.tar.gz
podman-7a2bca54f0194d7a4c5362e8e2a969ce54a367ba.tar.bz2
podman-7a2bca54f0194d7a4c5362e8e2a969ce54a367ba.zip
Merge pull request #2651 from mheon/prevent_null_deref
Fix a potential segfault in podman search
Diffstat (limited to 'cmd/podman/search.go')
-rw-r--r--cmd/podman/search.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/cmd/podman/search.go b/cmd/podman/search.go
index a10b9d419..e614887fc 100644
--- a/cmd/podman/search.go
+++ b/cmd/podman/search.go
@@ -83,11 +83,25 @@ func searchCmd(c *cliconfig.SearchValues) error {
if len(results) == 0 {
return nil
}
- out := formats.StdoutTemplateArray{Output: searchToGeneric(results), Template: format, Fields: genSearchOutputMap()}
+ out := formats.StdoutTemplateArray{Output: searchToGeneric(results), Template: format, Fields: searchHeaderMap()}
formats.Writer(out).Out()
return nil
}
+// searchHeaderMap returns the headers of a SearchResult.
+func searchHeaderMap() map[string]string {
+ s := new(image.SearchResult)
+ v := reflect.Indirect(reflect.ValueOf(s))
+ values := make(map[string]string, v.NumField())
+
+ for i := 0; i < v.NumField(); i++ {
+ key := v.Type().Field(i).Name
+ value := key
+ values[key] = strings.ToUpper(splitCamelCase(value))
+ }
+ return values
+}
+
func genSearchFormat(format string) string {
if format != "" {
// "\t" from the command line is not being recognized as a tab