From 7e0d0502aa057c6033187fec97fbb11c8cf93ab3 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Sun, 9 Feb 2020 00:41:50 -0800 Subject: [PATCH] Prevent panic on wrong interface conversion (#4803) * Prevent panic on wrong interface conversion * remove import --- beacon-chain/sync/rpc_goodbye.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beacon-chain/sync/rpc_goodbye.go b/beacon-chain/sync/rpc_goodbye.go index cda906204..0a0c83892 100644 --- a/beacon-chain/sync/rpc_goodbye.go +++ b/beacon-chain/sync/rpc_goodbye.go @@ -27,7 +27,10 @@ func (r *Service) goodbyeRPCHandler(ctx context.Context, msg interface{}, stream defer cancel() setRPCStreamDeadlines(stream) - m := msg.(uint64) + m, ok:= msg.(uint64) + if !ok { + return fmt.Errorf("wrong message type for goodbye, got %T, wanted uint64", msg) + } log := log.WithField("Reason", goodbyeMessage(m)) log.WithField("peer", stream.Conn().RemotePeer()).Info("Peer has sent a goodbye message") // closes all streams with the peer