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

Segfault due to missing error check with bad HostConfig settings #147

Open
claytonpeters opened this issue Aug 18, 2021 · 1 comment
Open

Comments

@claytonpeters
Copy link

In connector.go, line 264, a call to BuildRequest is made, but err is never checked before req is passed to SendRequest on line 265. In the event BuildRequest fails, which is possible if the Connector's HostConfig object has an invalid Host attribute (for example, if it's accidentally specified as a URL rather than an IP/hostname) then req is nil.

When this is passed to SendRequest, it is blindly passed to the Do method of net/http.Client which then segfaults.

There should probably be some error checking here to fail more gracefully and/or some validation of the contents of HostConfig in Init on line 174

@rhossili
Copy link
Contributor

rhossili commented Sep 4, 2021

@claytonpeters

IMO, there are two separate issues here.

  1. Totally agree that there should be a check for error returned by BuildRequest before calling SendRequest here.

  2. The above won't address the example case of an invalid Host attribute. As you suggested, this can be addressed by validating HostConfig in Init. In addition, I noticed that there's a call to ValidateConnector here that is supposed to perform a validation by actually making a connection. However, the implementation has been commented out (see https://github.com/infobloxopen/infoblox-go-client/blob/master/connector.go#L378-L384). Perhaps we can resurrect that?

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

2 participants