summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-11-03 10:25:38 -0500
committerCorey Hulen <corey@hulen.com>2017-11-03 08:25:38 -0700
commitd5dbdb273703a3add0f1c3287aa531854ab30269 (patch)
tree6b1fb9079f9fae9d25bdb7ea459261383ee720d6 /api4
parent9d32cd42085bbb37460d815c6c1a00ad881c4895 (diff)
downloadchat-d5dbdb273703a3add0f1c3287aa531854ab30269.tar.gz
chat-d5dbdb273703a3add0f1c3287aa531854ab30269.tar.bz2
chat-d5dbdb273703a3add0f1c3287aa531854ab30269.zip
several one-line panic, race, and logic fixes (#7766)
Diffstat (limited to 'api4')
-rw-r--r--api4/command.go4
-rw-r--r--api4/system.go2
-rw-r--r--api4/team.go8
3 files changed, 9 insertions, 5 deletions
diff --git a/api4/command.go b/api4/command.go
index 1a488b505..c92eb277a 100644
--- a/api4/command.go
+++ b/api4/command.go
@@ -156,8 +156,8 @@ func listCommands(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- commands := []*model.Command{}
- err := &model.AppError{}
+ var commands []*model.Command
+ var err *model.AppError
if customOnly {
if !c.App.SessionHasPermissionToTeam(c.Session, teamId, model.PERMISSION_MANAGE_SLASH_COMMANDS) {
c.SetPermissionError(model.PERMISSION_MANAGE_SLASH_COMMANDS)
diff --git a/api4/system.go b/api4/system.go
index f3278a7b5..7bc846766 100644
--- a/api4/system.go
+++ b/api4/system.go
@@ -315,11 +315,11 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
fileData := fileArray[0]
file, err := fileData.Open()
- defer file.Close()
if err != nil {
c.Err = model.NewAppError("addLicense", "api.license.add_license.open.app_error", nil, err.Error(), http.StatusBadRequest)
return
}
+ defer file.Close()
buf := bytes.NewBuffer(nil)
io.Copy(buf, file)
diff --git a/api4/team.go b/api4/team.go
index 58dcaca0d..fe5d7a266 100644
--- a/api4/team.go
+++ b/api4/team.go
@@ -623,10 +623,14 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
}
importFromArray, ok := r.MultipartForm.Value["importFrom"]
+ if !ok || len(importFromArray) < 1 {
+ c.Err = model.NewAppError("importTeam", "api.team.import_team.no_import_from.app_error", nil, "", http.StatusBadRequest)
+ return
+ }
importFrom := importFromArray[0]
fileSizeStr, ok := r.MultipartForm.Value["filesize"]
- if !ok {
+ if !ok || len(fileSizeStr) < 1 {
c.Err = model.NewAppError("importTeam", "api.team.import_team.unavailable.app_error", nil, "", http.StatusBadRequest)
return
}
@@ -651,11 +655,11 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
fileInfo := fileInfoArray[0]
fileData, err := fileInfo.Open()
- defer fileData.Close()
if err != nil {
c.Err = model.NewAppError("importTeam", "api.team.import_team.open.app_error", nil, err.Error(), http.StatusBadRequest)
return
}
+ defer fileData.Close()
var log *bytes.Buffer
switch importFrom {