diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-07-06 08:23:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 08:23:06 -0400 |
commit | 19d452c74efb96f718079d5a268ca51a8983c4bd (patch) | |
tree | be89d4719eefcdbfb551bec172566dd762eae7d1 /api/oauth.go | |
parent | b8fcf02bf5d625184045ae597cd35273fccb07e6 (diff) | |
download | chat-19d452c74efb96f718079d5a268ca51a8983c4bd.tar.gz chat-19d452c74efb96f718079d5a268ca51a8983c4bd.tar.bz2 chat-19d452c74efb96f718079d5a268ca51a8983c4bd.zip |
Fix connection leaks in push notifications, diagnostics and oauth (#3469)
Diffstat (limited to 'api/oauth.go')
-rw-r--r-- | api/oauth.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/api/oauth.go b/api/oauth.go index 072699321..f64fc638d 100644 --- a/api/oauth.go +++ b/api/oauth.go @@ -8,6 +8,7 @@ import ( b64 "encoding/base64" "fmt" "io" + "io/ioutil" "net/http" "net/url" "strconv" @@ -195,6 +196,11 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) { c.Err = err return } else { + defer func() { + ioutil.ReadAll(body) + body.Close() + }() + action := props["action"] switch action { case model.OAUTH_ACTION_SIGNUP: @@ -578,6 +584,10 @@ func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error()) } else { ar = model.AccessResponseFromJson(resp.Body) + defer func() { + ioutil.ReadAll(resp.Body) + resp.Body.Close() + }() if ar == nil { return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "") } |