Fix connection leaks in push notifications, diagnostics and oauth (#3469)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b8fcf02bf5
Коммит
19d452c74e
10
api/oauth.go
10
api/oauth.go
@@ -8,6 +8,7 @@ import (
|
|||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -195,6 +196,11 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
defer func() {
|
||||||
|
ioutil.ReadAll(body)
|
||||||
|
body.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
action := props["action"]
|
action := props["action"]
|
||||||
switch action {
|
switch action {
|
||||||
case model.OAUTH_ACTION_SIGNUP:
|
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())
|
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error())
|
||||||
} else {
|
} else {
|
||||||
ar = model.AccessResponseFromJson(resp.Body)
|
ar = model.AccessResponseFromJson(resp.Body)
|
||||||
|
defer func() {
|
||||||
|
ioutil.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
|
}()
|
||||||
if ar == nil {
|
if ar == nil {
|
||||||
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "")
|
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -803,8 +803,11 @@ func sendPushNotification(post *model.Post, user *model.User, channel *model.Cha
|
|||||||
request, _ := http.NewRequest("POST", *utils.Cfg.EmailSettings.PushNotificationServer+model.API_URL_SUFFIX_V1+"/send_push", strings.NewReader(msg.ToJson()))
|
request, _ := http.NewRequest("POST", *utils.Cfg.EmailSettings.PushNotificationServer+model.API_URL_SUFFIX_V1+"/send_push", strings.NewReader(msg.ToJson()))
|
||||||
|
|
||||||
l4g.Debug(utils.T("api.post.send_notifications_and_forget.push_notification.debug"), msg.DeviceId, msg.Message)
|
l4g.Debug(utils.T("api.post.send_notifications_and_forget.push_notification.debug"), msg.DeviceId, msg.Message)
|
||||||
if _, err := httpClient.Do(request); err != nil {
|
if resp, err := httpClient.Do(request); err != nil {
|
||||||
l4g.Error(utils.T("api.post.send_notifications_and_forget.push_notification.error"), user.Id, err)
|
l4g.Error(utils.T("api.post.send_notifications_and_forget.push_notification.error"), user.Id, err)
|
||||||
|
} else {
|
||||||
|
ioutil.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// notification sent, don't need to check other sessions
|
// notification sent, don't need to check other sessions
|
||||||
|
|||||||
@@ -205,6 +205,8 @@ func doSecurityAndDiagnostics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bulletins := model.SecurityBulletinsFromJson(res.Body)
|
bulletins := model.SecurityBulletinsFromJson(res.Body)
|
||||||
|
ioutil.ReadAll(res.Body)
|
||||||
|
res.Body.Close()
|
||||||
|
|
||||||
for _, bulletin := range bulletins {
|
for _, bulletin := range bulletins {
|
||||||
if bulletin.AppliesToVersion == model.CurrentVersion {
|
if bulletin.AppliesToVersion == model.CurrentVersion {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user