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

Fix segmentation fault in "aws_api_gateway_base_path_mapping" resource #8466

Conversation

richardc
Copy link
Contributor

It is possible for the mapping.BasePath, mapping.RestApiId, and
mapping.Stage to be nil when they have not been set for the
mapping.[1] When this occurs a nil pointer is dereferenced and terraform
segmentation faults.

Here we remove the blind derefrences and trust in the behaviour of
(*ResourceData).Set() to handle the nil pointer safely.

[1] https://github.com/hashicorp/terraform/blob/master/vendor/github.com/aws/aws-sdk-go/service/apigateway/api.go#L4892-L4904

It is possible for the `mapping.BasePath`, `mapping.RestApiId`, and
`mapping.Stage` to be nil when they have not been set for the
mapping.[1]  When this occurs a nil pointer is dereferenced and terraform
segmentation faults.

Here we remove the blind derefrences and trust in the behaviour of
(*ResourceData).Set() to handle the nil pointer safely.

[1] https://github.com/hashicorp/terraform/blob/master/vendor/github.com/aws/aws-sdk-go/service/apigateway/api.go#L4892-L4904
@stack72
Copy link
Contributor

stack72 commented Aug 25, 2016

Hi @richardc

Thanks so much for the PR here - you are indeed correct. We should pass the pointer into the Set func - that takes care of dereferencing it in the safe way :)

Will merge this when green!

Paul

@stack72 stack72 merged commit 9be1ff5 into hashicorp:master Aug 25, 2016
richardbowden pushed a commit to richardbowden/terraform that referenced this pull request Aug 27, 2016
hashicorp#8466)

It is possible for the `mapping.BasePath`, `mapping.RestApiId`, and
`mapping.Stage` to be nil when they have not been set for the
mapping.[1]  When this occurs a nil pointer is dereferenced and terraform
segmentation faults.

Here we remove the blind derefrences and trust in the behaviour of
(*ResourceData).Set() to handle the nil pointer safely.

[1] https://github.com/hashicorp/terraform/blob/master/vendor/github.com/aws/aws-sdk-go/service/apigateway/api.go#L4892-L4904
@BerndWessels
Copy link

BerndWessels commented Oct 10, 2016

@stack72 Hi, is this resolved? I still get this error with Terraform v0.7.5 :

* aws_api_gateway_base_path_mapping.SeoWebsite: SerializationError: failed decoding REST JSON error response
caused by: invalid character '<' looking for beginning of value

I also noticed that the api_id and state_name are empty in terraform.tfstate which seems wrong since the very first deployment succeeded.

            "aws_api_gateway_base_path_mapping.SeoWebsite": {
                "type": "aws_api_gateway_base_path_mapping",
                "depends_on": [
                    "aws_api_gateway_deployment.SeoWebsite",
                    "aws_api_gateway_domain_name.SeoWebsite",
                    "aws_api_gateway_rest_api.SeoWebsite"
                ],
                "primary": {
                    "id": "seo.domain.nz/",
                    "attributes": {
                        "api_id": "",
                        "base_path": "",
                        "domain_name": "seo.domain.nz",
                        "id": "seo.domain.nz/",
                        "stage_name": ""
                    },
                    "meta": {},
                    "tainted": false
                },
                "deposed": [],
                "provider": ""
            },

@richardc
Copy link
Contributor Author

@BerndWessels This change only targeted the segmentation fault that was possible with the code at the time. That you are managing to generate invalid configurations still would be a new issue, so it's probably better to continue this discussion in #8953

@richardc richardc deleted the bug/segfault_aws_api_gateway_base_path_mapping branch May 25, 2017 08:26
@ghost
Copy link

ghost commented Apr 12, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants