skip reading needle if size is invalid

related to https://github.com/seaweedfs/seaweedfs/issues/3882
This commit is contained in:
chrislu 2022-10-23 14:00:15 -07:00
parent 5294b6dd4d
commit e3ea544d40
2 changed files with 4 additions and 0 deletions

View file

@ -24,6 +24,7 @@ const (
) )
var ErrorSizeMismatch = errors.New("size mismatch") var ErrorSizeMismatch = errors.New("size mismatch")
var ErrorSizeInvalid = errors.New("size invalid")
func (n *Needle) DiskSize(version Version) int64 { func (n *Needle) DiskSize(version Version) int64 {
return GetActualSize(n.Size, version) return GetActualSize(n.Size, version)

View file

@ -43,6 +43,9 @@ func (n *Needle) ReadNeedleMeta(r backend.BackendStorageFile, offset int64, size
return ErrorSizeMismatch return ErrorSizeMismatch
} }
} }
if !n.Size.IsValid() {
return ErrorSizeInvalid
}
n.DataSize = util.BytesToUint32(bytes[NeedleHeaderSize : NeedleHeaderSize+DataSizeSize]) n.DataSize = util.BytesToUint32(bytes[NeedleHeaderSize : NeedleHeaderSize+DataSizeSize])
startOffset := offset + NeedleHeaderSize + DataSizeSize + int64(n.DataSize) startOffset := offset + NeedleHeaderSize + DataSizeSize + int64(n.DataSize)