Skip to content
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

Assignment to entry in nil map in ServiceClient.Request #2798

Closed
dtantsur opened this issue Oct 6, 2023 · 0 comments
Closed

Assignment to entry in nil map in ServiceClient.Request #2798

dtantsur opened this issue Oct 6, 2023 · 0 comments

Comments

@dtantsur
Copy link
Contributor

dtantsur commented Oct 6, 2023

The code writes to MoreHeaders without initializing it. The actual initialization happens in Get/Post/etc, so if you use Request directly, you can get:

panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/gophercloud/gophercloud.(*ServiceClient).Request(0xc00010fa90, {0x6efecb, 0x3}, {0xc00001e100, 0x1a}, 0xc?)
        /home/dtantsur/gophercloud/service_client.go:150 +0x147
github.com/gophercloud/gophercloud/openstack/utils.GetSupportedMicroversions({0xc00013c000, {0xc00001e100, 0x1a}, {0x0, 0x0}, {0x6f117e, 0x9}, {0x0, 0x0}, 0xc00002ac90})
        /home/dtantsur/gophercloud/openstack/utils/choose_version.go:130 +0xd1
main.main()
        /home/dtantsur/gophercloud/main/main.go:26 +0x98
pierreprinetti added a commit that referenced this issue Oct 6, 2023
Fix options initialization in ServiceClient.Request (fixes #2798)
gophercloud-backport-bot bot pushed a commit that referenced this issue Oct 6, 2023
Request is a part of the public API, but it relies on being called by
Get/Post/etc to properly initialize its options. Namely:
1) it may crash on a nil map assignment if there are MoreHeaders,
2) it does not handle microversions.

This change moves the relevant code to Request.
mandre added a commit that referenced this issue Oct 9, 2023
[v1] Fix options initialization in ServiceClient.Request (fixes #2798)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant