Browse Source

skip reading needle if size is invalid

related to https://github.com/seaweedfs/seaweedfs/issues/3882
pull/3895/head
chrislu 2 years ago
parent
commit
e3ea544d40
  1. 1
      weed/storage/needle/needle_read.go
  2. 3
      weed/storage/needle/needle_read_page.go

1
weed/storage/needle/needle_read.go

@ -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)

3
weed/storage/needle/needle_read_page.go

@ -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)

Loading…
Cancel
Save