From e8f9bee8229d1bec1fce8dc81eda70e1acf47b69 Mon Sep 17 00:00:00 2001 From: Ian Denhardt Date: Mon, 24 Aug 2020 17:59:28 -0400 Subject: [PATCH] Don't panic when Payload is null. 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. --- rpc/rpc.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpc/rpc.go b/rpc/rpc.go index 18d7209e..6a87b910 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -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")