From 84fa87828b2e632bb79ef09a20875c68c5717023 Mon Sep 17 00:00:00 2001 From: Will Scott Date: Sun, 8 Mar 2020 15:21:16 -0700 Subject: [PATCH] specificity edge cases --- common.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common.go b/common.go index fda18f5..2a9a6ea 100644 --- a/common.go +++ b/common.go @@ -135,8 +135,14 @@ func (r *router) route(routes routeSlice, input net.HardwareAddr, src, dst net.I continue } if mostSpecificRt != nil { - candSpec, _ := rt.Dst.Mask.Size() - if curSpec, _ := mostSpecificRt.Dst.Mask.Size(); candSpec < curSpec { + var candSpec, curSpec int + if rt.Dst != nil { + candSpec, _ = rt.Dst.Mask.Size() + } + if mostSpecificRt.Dst != nil { + curSpec, _ = mostSpecificRt.Dst.Mask.Size() + } + if candSpec < curSpec { continue } }