summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-08-20 10:09:21 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-08-25 15:53:14 +0900
commit17331d161fae507424a9760a9dbca41b3669ed36 (patch)
tree90a2a1d07b1dfb73e544b39cc30dc16d5d049b1e /server/server.go
parentb0bead46c891e9dcc3dd7e8d347fc460c8db78b0 (diff)
server: handle error of net.ParseCIDR()
invalid key could crash BgpServer
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/server/server.go b/server/server.go
index bc0aa59c..d3f05853 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1483,7 +1483,10 @@ func (s *BgpServer) GetRib(addr string, family bgp.RouteFamily, prefixes []*Look
key := p.Prefix
switch p.LookupOption {
case LOOKUP_LONGER:
- _, prefix, _ := net.ParseCIDR(key)
+ _, prefix, err := net.ParseCIDR(key)
+ if err != nil {
+ return id, nil, err
+ }
for _, dst := range rib.Tables[af].GetLongerPrefixDestinations(prefix.String()) {
if paths := dst.GetKnownPathList(id); len(paths) > 0 {
dsts[dst.GetNlri().String()] = clonePathList(paths)
@@ -1491,7 +1494,10 @@ func (s *BgpServer) GetRib(addr string, family bgp.RouteFamily, prefixes []*Look
}
case LOOKUP_SHORTER:
- _, prefix, _ := net.ParseCIDR(key)
+ _, prefix, err := net.ParseCIDR(key)
+ if err != nil {
+ return id, nil, err
+ }
ones, bits := prefix.Mask.Size()
for i := ones; i > 0; i-- {
prefix.Mask = net.CIDRMask(i, bits)