fix: allow payload verification error to be returned (#15364)

without reading the reader the error is ignored
by the custom unmarshaller written by ObjectLegalHold
data structure.
This commit is contained in:
Harshavardhana
2022-07-21 01:24:03 -07:00
committed by GitHub
parent c6ecaf68ed
commit 8249cd4406
3 changed files with 12 additions and 4 deletions

View File

@@ -18,6 +18,7 @@
package lock
import (
"bytes"
"context"
"encoding/xml"
"errors"
@@ -529,8 +530,13 @@ func (l *ObjectLegalHold) IsEmpty() bool {
// ParseObjectLegalHold decodes the XML into ObjectLegalHold
func ParseObjectLegalHold(reader io.Reader) (hold *ObjectLegalHold, err error) {
buf, err := io.ReadAll(io.LimitReader(reader, maxObjectLockConfigSize))
if err != nil {
return nil, err
}
hold = &ObjectLegalHold{}
if err = xml.NewDecoder(reader).Decode(hold); err != nil {
if err = xml.NewDecoder(bytes.NewReader(buf)).Decode(hold); err != nil {
return nil, err
}