Skip to content

Commit

Permalink
validate deal proposal (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense authored and dirkmc committed Apr 15, 2022
1 parent c06e4d0 commit 742e140
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions storagemarket/impl/provider.go
Original file line number Diff line number Diff line change
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 742e140

Please sign in to comment.