Skip to content

Commit

Permalink
Don't panic when Payload is null. (#157)
Browse files Browse the repository at this point in the history
This patch fixes an issue where a null Payload in a Return or Call
message could cause the rpc logic to panic. Instead, we just treat a
null payload the same as an empty one.
  • Loading branch information
zenhack authored Aug 24, 2020
1 parent e89f9b7 commit 5246e51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,11 @@ func (c *Conn) recvCap(d rpccp.CapDescriptor) (_ *capnp.Client, local bool, _ er
//
// The caller must be holding onto c.mu.
func (c *Conn) recvPayload(payload rpccp.Payload) (_ capnp.Ptr, locals uintSet, _ error) {
if !payload.IsValid() {
// null pointer; in this case we can treat the cap table as being empty
// and just return.
return capnp.Ptr{}, nil, nil
}
if payload.Message().CapTable != nil {
// RecvMessage likely violated its invariant.
return capnp.Ptr{}, nil, fail("read payload: capability table already populated")
Expand Down

0 comments on commit 5246e51

Please sign in to comment.