From 1265ce0cd508817c1bfebbb1ebdafae5ef82e40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Tue, 24 Sep 2019 16:11:22 +0200 Subject: [PATCH] pkg/route: filter invalid route updates This commit fixes the underlying issue that caused crashes when receiving a nil route update, as reported in https://github.com/squat/kilo/issues/17. --- pkg/route/route.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/route/route.go b/pkg/route/route.go index 9de04ae..feb880d 100644 --- a/pkg/route/route.go +++ b/pkg/route/route.go @@ -91,6 +91,10 @@ func (t *Table) Run(stop <-chan struct{}) (<-chan error, error) { case unix.RTM_DELROUTE: t.mu.Lock() for _, r := range t.routes { + // Filter out invalid routes. + if r == nil || r.Dst == nil { + continue + } // If any deleted route's destination matches a destination // in the table, reset the corresponding route just in case. if r.Dst.IP.Equal(e.Route.Dst.IP) && r.Dst.Mask.String() == e.Route.Dst.Mask.String() {