Part ID check (#1730)

* Added check in PutObjectPartHandler to make sure part ID does not exceed 10000. ErrInvalidMaxParts written to response if part ID exceeds the maximum value.
master
Aakash Muttineni 9 years ago committed by Harshavardhana
parent 584813e214
commit b48b2e7f7c
  1. 6
      object-handlers.go
  2. 7
      utils.go

@ -741,6 +741,12 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
return return
} }
// check partID with maximum part ID for multipart objects
if isMaxPartID(partID) {
writeErrorResponse(w, r, ErrInvalidMaxParts, r.URL.Path)
return
}
var partMD5 string var partMD5 string
switch getRequestAuthType(r) { switch getRequestAuthType(r) {
default: default:

@ -40,6 +40,8 @@ const (
maxObjectSize = 1024 * 1024 * 1024 * 5 maxObjectSize = 1024 * 1024 * 1024 * 5
// minimum Part size for multipart upload is 5MB // minimum Part size for multipart upload is 5MB
minPartSize = 1024 * 1024 * 5 minPartSize = 1024 * 1024 * 5
// maximum Part ID for multipart upload is 10000 (Acceptable values range from 1 to 10000 inclusive)
maxPartID = 10000
) )
// isMaxObjectSize - verify if max object size // isMaxObjectSize - verify if max object size
@ -52,6 +54,11 @@ func isMinAllowedPartSize(size int64) bool {
return size >= minPartSize return size >= minPartSize
} }
// isMaxPartNumber - Check if part ID is greater than the maximum allowed ID.
func isMaxPartID(partID int) bool {
return partID > maxPartID
}
func contains(stringList []string, element string) bool { func contains(stringList []string, element string) bool {
for _, e := range stringList { for _, e := range stringList {
if e == element { if e == element {

Loading…
Cancel
Save