From f32ef660178d01af79a89162e2bae3a0a1d61371 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Thu, 14 Apr 2022 14:39:31 +0200 Subject: [PATCH] validate deal proposal --- storagemarket/impl/provider.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/storagemarket/impl/provider.go b/storagemarket/impl/provider.go index 0d9aa61f..bf4b8f2c 100644 --- a/storagemarket/impl/provider.go +++ b/storagemarket/impl/provider.go @@ -261,6 +261,10 @@ func (p *Provider) receiveDeal(s network.StorageDealStream) error { return xerrors.Errorf("failed to read proposal message: %w", err) } + if proposal.DealProposal == nil { + return xerrors.Errorf("failed to get deal proposal from proposal message") + } + proposalNd, err := cborutil.AsIpld(proposal.DealProposal) if err != nil { return err @@ -274,6 +278,10 @@ func (p *Provider) receiveDeal(s network.StorageDealStream) error { return p.resendProposalResponse(s, &md) } + if proposal.Piece == nil { + return xerrors.Errorf("failed to get proposal piece from proposal message") + } + var path string // create an empty CARv2 file at a temp location that Graphysnc will write the incoming blocks to via a CARv2 ReadWrite blockstore wrapper. if proposal.Piece.TransferType != storagemarket.TTManual {