diff options
author | =Corey Hulen <corey@hulen.com> | 2015-10-27 11:52:13 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-10-27 11:52:13 -0700 |
commit | a133f82421d2c67ef32b0aae69a6646a14f97dfc (patch) | |
tree | 35fe7dcf6b208437111c5d3a843eabf2f4703101 /api/user.go | |
parent | e22b9f53034280cd3b730c03520469dca4046484 (diff) | |
parent | e0f69060fa462390779dd7b4cf6b67a12c3974ba (diff) | |
download | chat-a133f82421d2c67ef32b0aae69a6646a14f97dfc.tar.gz chat-a133f82421d2c67ef32b0aae69a6646a14f97dfc.tar.bz2 chat-a133f82421d2c67ef32b0aae69a6646a14f97dfc.zip |
Merge branch 'master' into PLT-340
Diffstat (limited to 'api/user.go')
-rw-r--r-- | api/user.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/api/user.go b/api/user.go index 06e5336f1..3796a50ee 100644 --- a/api/user.go +++ b/api/user.go @@ -855,6 +855,18 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { return } + // Decode image config first to check dimensions before loading the whole thing into memory later on + config, _, err := image.DecodeConfig(file) + if err != nil { + c.Err = model.NewAppError("uploadProfileFile", "Could not decode profile image config.", err.Error()) + return + } else if config.Width*config.Height > MaxImageSize { + c.Err = model.NewAppError("uploadProfileFile", "Unable to upload profile image. File is too large.", err.Error()) + return + } + + file.Seek(0, 0) + // Decode image into Image object img, _, err := image.Decode(file) if err != nil { |