From a4e520aff16b607c0cf5558fbcfc0dc2cf41d9d8 Mon Sep 17 00:00:00 2001 From: Trapier Marshall Date: Fri, 20 Sep 2019 11:47:50 -0400 Subject: [PATCH] Fix nil pointer deref in dump-snapshot --redacted container.PullOptions is nil if the service is deployed without `--with-registry-auth`. Observed on client+server 19.03.2. Signed-off-by: Trapier Marshall --- cmd/swarm-rafttool/dump.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/swarm-rafttool/dump.go b/cmd/swarm-rafttool/dump.go index 6360194d67..481a0ba6c4 100644 --- a/cmd/swarm-rafttool/dump.go +++ b/cmd/swarm-rafttool/dump.go @@ -200,7 +200,9 @@ func dumpSnapshot(swarmdir, unlockKey string, redact bool) error { if task != nil { if container := task.Spec.GetContainer(); container != nil { container.Env = []string{"ENVVARS REDACTED"} - container.PullOptions.RegistryAuth = "REDACTED" + if container.PullOptions != nil { + container.PullOptions.RegistryAuth = "REDACTED" + } } } } @@ -208,7 +210,9 @@ func dumpSnapshot(swarmdir, unlockKey string, redact bool) error { if service != nil { if container := service.Spec.Task.GetContainer(); container != nil { container.Env = []string{"ENVVARS REDACTED"} - container.PullOptions.RegistryAuth = "REDACTED" + if container.PullOptions != nil { + container.PullOptions.RegistryAuth = "REDACTED" + } } } }