DeviaVir / terraform-provider-gsuite

A @HashiCorp Terraform provider for managing G Suite resources.
MIT License
271 stars 77 forks source link

catch the case where an non-email is provided #152

Closed mathyourlife-fitbit closed 4 years ago

mathyourlife-fitbit commented 4 years ago

Ran into a case where a non-email address is supplied to the validateEmail function.

2020-08-19T00:23:04.610Z [DEBUG] plugin.terraform-provider-gsuite_v0.1.54: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xe0d055]
2020-08-19T00:23:04.610Z [DEBUG] plugin.terraform-provider-gsuite_v0.1.54: 
2020-08-19T00:23:04.610Z [DEBUG] plugin.terraform-provider-gsuite_v0.1.54: goroutine 2535 [running]:
2020-08-19T00:23:04.610Z [DEBUG] plugin.terraform-provider-gsuite_v0.1.54: github.com/DeviaVir/terraform-provider-gsuite/gsuite.validateEmail(0xeb9fa0, 0xc00031f810, 0x1090b3e, 0x5, 0x0, 0x0, 0x4b90dd, 0xf10660, 0xc00031f390, 0x94)
2020-08-19T00:23:04.610Z [DEBUG] plugin.terraform-provider-gsuite_v0.1.54:  /go/src/github.com/DeviaVir/terraform-provider-gsuite/gsuite/utils.go:192 +0x105

This matches a simplified test case:

package main
import (
    "fmt"
    "net/mail"
)
func main() {
    e, _ := mail.ParseAddress("not an email address")
    fmt.Println(e.Name)
}
go run main.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10c25a2]

goroutine 1 [running]:
main.main()
    /go/src/main.go:10 +0x72
exit status 2