sealing: Validate piece alignment in checkPieces

This commit is contained in:
Łukasz Magiera 2022-08-25 20:53:21 -04:00
parent 332d83bd18
commit ca790b4c69

View File

@ -49,8 +49,15 @@ func checkPieces(ctx context.Context, maddr address.Address, sn abi.SectorNumber
}
dealCount := 0
var offset abi.PaddedPieceSize
for i, p := range pieces {
// check that the piece is correctly aligned
if offset%p.Piece.Size != 0 {
return &ErrInvalidPiece{xerrors.Errorf("sector %d piece %d is not aligned: size=%xh offset=%xh off-by=%xh", sn, i, p.Piece.Size, offset, offset%p.Piece.Size)}
}
offset += p.Piece.Size
// if no deal is associated with the piece, ensure that we added it as
// filler (i.e. ensure that it has a zero PieceCID)
if p.DealInfo == nil {