From f32731f9020f12ae2600a3f4c90e668565220cb6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 29 Oct 2020 01:39:30 +0100 Subject: [PATCH] GetDefaultAuthConfig: fix potential panic due to unhandled error Signed-off-by: Sebastiaan van Stijn --- cli/command/registry.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cli/command/registry.go b/cli/command/registry.go index 86fba0598d..68cb43144d 100644 --- a/cli/command/registry.go +++ b/cli/command/registry.go @@ -93,17 +93,18 @@ func GetDefaultAuthConfig(cli Cli, checkCredStore bool, serverAddress string, is if !isDefaultRegistry { serverAddress = registry.ConvertToHostname(serverAddress) } - var authconfig configtypes.AuthConfig + var authconfig = configtypes.AuthConfig{} var err error if checkCredStore { authconfig, err = cli.ConfigFile().GetAuthConfig(serverAddress) - } else { - authconfig = configtypes.AuthConfig{} + if err != nil { + return nil, err + } } authconfig.ServerAddress = serverAddress authconfig.IdentityToken = "" res := types.AuthConfig(authconfig) - return &res, err + return &res, nil } // ConfigureAuth handles prompting of user's username and password if needed