fix: reused field crash in PartIndices (#15351)

`PartIndices` may be set if xlMetaV2Version is reused.

Clear before unmarshaling and add sanity check when reading.
This commit is contained in:
Klaus Post
2022-07-19 16:49:46 -07:00
committed by GitHub
parent f939d1c183
commit cae9aeca00
2 changed files with 5 additions and 1 deletions

View File

@@ -83,6 +83,10 @@ func (j *xlMetaV2Version) unmarshalV(v uint8, bts []byte) (o []byte, err error)
switch v {
// We accept un-set as latest version.
case 0, xlMetaVersion:
// Clear omitempty fields:
if j.ObjectV2 != nil && len(j.ObjectV2.PartIndices) > 0 {
j.ObjectV2.PartIndices = j.ObjectV2.PartIndices[:0]
}
o, err = j.UnmarshalMsg(bts)
// Clean up PartEtags on v1