return appropriate errors upon parseErrors (#13831)

This commit is contained in:
Harshavardhana 2021-12-05 11:36:26 -08:00 committed by GitHub
parent f6190d6751
commit 8591d17d82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -3533,9 +3533,11 @@ func (api objectAPIHandlers) PutObjectLegalHoldHandler(w http.ResponseWriter, r
return return
} }
legalHold, err := objectlock.ParseObjectLegalHold(r.Body) legalHold, err := objectlock.ParseObjectLegalHold(io.LimitReader(r.Body, r.ContentLength))
if err != nil { if err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) apiErr := errorCodes.ToAPIErr(ErrMalformedXML)
apiErr.Description = err.Error()
writeErrorResponse(ctx, w, apiErr, r.URL)
return return
} }

View File

@ -535,7 +535,7 @@ func (l *ObjectLegalHold) IsEmpty() bool {
func ParseObjectLegalHold(reader io.Reader) (hold *ObjectLegalHold, err error) { func ParseObjectLegalHold(reader io.Reader) (hold *ObjectLegalHold, err error) {
hold = &ObjectLegalHold{} hold = &ObjectLegalHold{}
if err = xml.NewDecoder(reader).Decode(hold); err != nil { if err = xml.NewDecoder(reader).Decode(hold); err != nil {
return return nil, err
} }
if !hold.Status.Valid() { if !hold.Status.Valid() {