handlers: read ContentLength value directly from http.Request.

Do not look for Content-Length in headers and try to convert them into
integer representations use ContentLength field from *http.Request*.

If Content-Length is understood to be as '-1' then treat it as an error
condition, since it could be a malformed body to crash the server.

Fixes #1011
This commit is contained in:
Harshavardhana
2015-12-27 23:00:36 -08:00
parent 7aab7ba946
commit 2f67559684
3 changed files with 19 additions and 46 deletions
+3 -8
View File
@@ -18,7 +18,6 @@ package main
import (
"encoding/base64"
"strconv"
"strings"
)
@@ -36,17 +35,13 @@ func isValidMD5(md5 string) bool {
/// http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadingObjects.html
const (
// maximum object size per PUT request is 5GB
// maximum object size per PUT request is 5GiB
maxObjectSize = 1024 * 1024 * 1024 * 5
)
// isMaxObjectSize - verify if max object size
func isMaxObjectSize(size string) bool {
i, err := strconv.ParseInt(size, 10, 64)
if err != nil {
return true
}
if i > maxObjectSize {
func isMaxObjectSize(size int64) bool {
if size > maxObjectSize {
return true
}
return false