Skip to content

Commit

Permalink
validate deal proposal (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Apr 14, 2022
1 parent 879ca09 commit 35fd57c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions storagemarket/impl/provider.go
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 35fd57c

Please sign in to comment.