-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nil pointer dereference on loading the config file #4414
Labels
Comments
Danial-Gharib
added a commit
to Danial-Gharib/cli
that referenced
this issue
Jul 12, 2023
Danial-Gharib
added a commit
to Danial-Gharib/cli
that referenced
this issue
Jul 13, 2023
Signed-off-by: Danial Gharib <[email protected]>
thaJeztah
added a commit
that referenced
this issue
Jul 19, 2023
Fix nil pointer dereference issue (#4414)
@thaJeztah Where can we find this fix? We have a Windows 11 machine running Docker v4.21.1 which is hitting this issue. For some reason our other machines on the same docker version haven't hit it, although, they are mostly Windows 10. |
The fix is a part of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The following line causes a
nil
pointer dereference ifauths
is set tonull
inconfig.json
:cli/cli/config/credentials/file_store.go
Line 55 in df04aca
configfile.LoadFromReader()
would overrideAuthConfigs
and set it tonil
even if it has been initialised to an empty map inNew()
prior to that:cli/cli/config/configfile/file.go
Line 58 in df04aca
cli/cli/config/config.go
Line 113 in df04aca
One doesn't need to manually edit the file for that to be the case as it can result from a failed login. The
AuthConfigs
field in theConfigFile
struct doesn't have anomitempty
tag, therefore anull
value is explicitly set in the marshalled JSON:cli/cli/config/configfile/file.go
Line 19 in df04aca
Therefore it is recommended to check explicitly if the output of
c.file.GetAuthConfigs()
isnil
and/or return an empty map if the value isnil
in:cli/cli/config/configfile/file.go
Line 97 in df04aca
Additionally, adding an
omitempty
tag for the field may be advised, even though it must be noted thatomitempty
doesn't differentiate between an empty map andnil
.Reproduce
"auths": null
in~/.docker/config.json
docker login
Expected behavior
No response
docker version
Client: Cloud integration: v1.0.35 Version: 24.0.2 API version: 1.43 Go version: go1.20.4 Git commit: cb74dfc Built: Thu May 25 21:53:15 2023 OS/Arch: windows/amd64 Context: default Server: Docker Desktop 4.21.1 (114176) Engine: Version: 24.0.2 API version: 1.43 (minimum version 1.24) Go version: go1.20.4 Git commit: 659604f9 Built: Thu May 25 21:52:13 2023 OS/Arch: windows/amd64 Experimental: false
docker info
Additional Info
docker login
output and stack trace:Debugger output:
The text was updated successfully, but these errors were encountered: