diff --git a/weed/storage/needle/needle_read.go b/weed/storage/needle/needle_read.go index 55d0cc893..620591898 100644 --- a/weed/storage/needle/needle_read.go +++ b/weed/storage/needle/needle_read.go @@ -24,6 +24,7 @@ const ( ) var ErrorSizeMismatch = errors.New("size mismatch") +var ErrorSizeInvalid = errors.New("size invalid") func (n *Needle) DiskSize(version Version) int64 { return GetActualSize(n.Size, version) diff --git a/weed/storage/needle/needle_read_page.go b/weed/storage/needle/needle_read_page.go index 47c3461bb..4e7edfb31 100644 --- a/weed/storage/needle/needle_read_page.go +++ b/weed/storage/needle/needle_read_page.go @@ -43,6 +43,9 @@ func (n *Needle) ReadNeedleMeta(r backend.BackendStorageFile, offset int64, size return ErrorSizeMismatch } } + if !n.Size.IsValid() { + return ErrorSizeInvalid + } n.DataSize = util.BytesToUint32(bytes[NeedleHeaderSize : NeedleHeaderSize+DataSizeSize]) startOffset := offset + NeedleHeaderSize + DataSizeSize + int64(n.DataSize)